gaesup-world 0.7.2 → 0.7.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 +5 -5
- package/dist/gaesup/component/active/character/index.js +1 -1
- package/dist/gaesup/component/index.js +2 -2
- package/dist/gaesup/component/inner/character/index.js +1 -1
- package/dist/gaesup/component/inner/character/type.d.ts +4 -1
- package/dist/gaesup/component/inner/common/RigidbodyRef.d.ts +3 -1
- package/dist/gaesup/component/inner/common/RigidbodyRef.js +16 -29
- package/dist/gaesup/component/inner/common/type.d.ts +3 -1
- package/dist/gaesup/component/passive/character/index.js +1 -1
- package/dist/gaesup/component/passive/type.d.ts +2 -1
- package/dist/gaesup/controller/initialize/callback/index.d.ts +9 -5
- package/dist/gaesup/controller/initialize/callback/index.js +31 -42
- package/dist/gaesup/controller/initialize/callback/type.d.ts +1 -4
- package/dist/gaesup/controller/initialize/index.js +1 -1
- package/dist/gaesup/physics/check/ground.js +6 -9
- package/dist/gaesup/physics/check/moving.js +3 -1
- package/dist/gaesup/tools/miniMap/index.js +11 -3
- package/dist/gaesup/tools/miniMap/style.css +6 -3
- package/package.json +5 -3
package/README.md
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
# Gaesup World
|
|
2
2
|
|
|
3
|
-
[](https://www.npmjs.com/package/../../../src)
|
|
4
|
+
[](https://www.npmjs.com/package/../../../src)
|
|
5
5
|
|
|
6
6
|
### Web 3D Character Controller and World Platform Library
|
|
7
7
|
|
|
8
|
-
### 
|
|
9
9
|
|
|
10
10
|
## introduction
|
|
11
11
|
|
|
@@ -50,13 +50,13 @@ export default function App() {
|
|
|
50
50
|
## Installation
|
|
51
51
|
|
|
52
52
|
```bash
|
|
53
|
-
npm install @react-three/fiber @react-three/drei three @types/three @react-three/rapier
|
|
53
|
+
npm install @react-three/fiber @react-three/drei three @types/three @react-three/rapier ../../../src
|
|
54
54
|
```
|
|
55
55
|
|
|
56
56
|
Or
|
|
57
57
|
|
|
58
58
|
```bash
|
|
59
|
-
yarn add @react-three/fiber @react-three/drei three @types/three @react-three/rapier
|
|
59
|
+
yarn add @react-three/fiber @react-three/drei three @types/three @react-three/rapier ../../../src
|
|
60
60
|
```
|
|
61
61
|
|
|
62
62
|
## 4) How to Contribute
|
|
@@ -13,5 +13,5 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
13
13
|
import { CharacterInnerRef } from "../../inner/character";
|
|
14
14
|
export function CharacterRef(_a) {
|
|
15
15
|
var props = _a.props, refs = _a.refs, urls = _a.urls;
|
|
16
|
-
return (_jsx(CharacterInnerRef, __assign({ url: urls.characterUrl, isActive: true, componentType: "character", rigidbodyType: "dynamic", controllerOptions: props.controllerOptions }, refs, { children: props.children })));
|
|
16
|
+
return (_jsx(CharacterInnerRef, __assign({ url: urls.characterUrl, isActive: true, componentType: "character", rigidbodyType: "dynamic", controllerOptions: props.controllerOptions, groundRay: props.groundRay, onAnimate: props.onAnimate, onFrame: props.onFrame, onReady: props.onReady, onDestory: props.onDestory }, refs, { children: props.children })));
|
|
17
17
|
}
|
|
@@ -20,9 +20,9 @@ export function GaesupComponent(_a) {
|
|
|
20
20
|
var props = _a.props, refs = _a.refs, urls = _a.urls;
|
|
21
21
|
var _b = useContext(GaesupWorldContext), mode = _b.mode, states = _b.states, rideable = _b.rideable;
|
|
22
22
|
var enableRiding = states.enableRiding, isRiderOn = states.isRiderOn, rideableId = states.rideableId;
|
|
23
|
-
return (_jsxs(_Fragment, { children: [mode.type === "character" && (_jsx(CharacterRef, { props: props, refs: refs, urls: urls })), mode.type === "vehicle" && (_jsx(VehicleRef, __assign({ controllerOptions: props.controllerOptions, url: urls.vehicleUrl, wheelUrl: urls.wheelUrl, ridingUrl: urls.ridingUrl, enableRiding: enableRiding, isRiderOn: isRiderOn, offset: rideableId && rideable[rideableId]
|
|
23
|
+
return (_jsxs(_Fragment, { children: [mode.type === "character" && (_jsx(CharacterRef, { props: props, refs: refs, urls: urls })), mode.type === "vehicle" && (_jsx(VehicleRef, __assign({ controllerOptions: props.controllerOptions, url: urls.vehicleUrl, wheelUrl: urls.wheelUrl, ridingUrl: urls.ridingUrl, enableRiding: enableRiding, isRiderOn: isRiderOn, groundRay: props.groundRay, offset: rideableId && rideable[rideableId]
|
|
24
24
|
? rideable[rideableId].offset
|
|
25
|
-
: vec3() }, refs, { children: props.children }))), mode.type === "airplane" && (_jsx(AirplaneRef, __assign({ controllerOptions: props.controllerOptions, url: urls.airplaneUrl, ridingUrl: urls.ridingUrl, enableRiding: enableRiding, isRiderOn: isRiderOn, offset: rideableId && rideable[rideableId]
|
|
25
|
+
: vec3() }, refs, { children: props.children }))), mode.type === "airplane" && (_jsx(AirplaneRef, __assign({ controllerOptions: props.controllerOptions, url: urls.airplaneUrl, ridingUrl: urls.ridingUrl, enableRiding: enableRiding, isRiderOn: isRiderOn, groundRay: props.groundRay, offset: rideableId && rideable[rideableId]
|
|
26
26
|
? rideable[rideableId].offset
|
|
27
27
|
: vec3() }, refs, { children: props.children })))] }));
|
|
28
28
|
}
|
|
@@ -14,5 +14,5 @@ import { OuterGroupRef } from "../common/OuterGroupRef";
|
|
|
14
14
|
import { RigidBodyRef } from "../common/RigidbodyRef";
|
|
15
15
|
export function CharacterInnerRef(props) {
|
|
16
16
|
var outerGroupRef = props.outerGroupRef;
|
|
17
|
-
return (_jsx(OuterGroupRef, { ref: outerGroupRef, children: _jsx(RigidBodyRef, __assign({ name: "character", url: props.url, controllerOptions: props.controllerOptions, ref: props.rigidBodyRef }, props, { children: props.children })) }));
|
|
17
|
+
return (_jsx(OuterGroupRef, { ref: outerGroupRef, children: _jsx(RigidBodyRef, __assign({ name: "character", url: props.url, controllerOptions: props.controllerOptions, ref: props.rigidBodyRef, groundRay: props.groundRay }, props, { children: props.children })) }));
|
|
18
18
|
}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
import { callbackType } from "../../../controller/initialize/callback/type";
|
|
2
|
+
import { groundRayType } from "../../../controller/type";
|
|
1
3
|
import { passiveCharacterPropsType } from "../../passive/character/type";
|
|
2
4
|
import { componentTypeString, innerRefType } from "../../passive/type";
|
|
3
5
|
export type characterInnerType = {
|
|
4
6
|
componentType: componentTypeString;
|
|
5
7
|
isActive?: boolean;
|
|
6
|
-
|
|
8
|
+
groundRay: groundRayType;
|
|
9
|
+
} & passiveCharacterPropsType & innerRefType & callbackType;
|
|
@@ -9,8 +9,10 @@ export declare const RigidBodyRef: import("react").ForwardRefExoticComponent<{
|
|
|
9
9
|
onCollisionEnter?: (e: import("@react-three/rapier").CollisionEnterPayload) => Promise<void>;
|
|
10
10
|
isActive?: boolean;
|
|
11
11
|
ridingUrl?: string;
|
|
12
|
+
groundRay?: import("../../../controller/type").groundRayType;
|
|
12
13
|
} & {
|
|
13
14
|
children?: import("react").ReactNode;
|
|
15
|
+
groundRay?: import("../../../controller/type").groundRayType;
|
|
14
16
|
url: string;
|
|
15
17
|
ridingUrl?: string;
|
|
16
18
|
wheelUrl?: string;
|
|
@@ -25,4 +27,4 @@ export declare const RigidBodyRef: import("react").ForwardRefExoticComponent<{
|
|
|
25
27
|
userData?: {
|
|
26
28
|
intangible: boolean;
|
|
27
29
|
};
|
|
28
|
-
} & import("./type").ridingType & import("../../passive/type").innerRefType & import("react").RefAttributes<RapierRigidBody>>;
|
|
30
|
+
} & import("./type").ridingType & import("../../passive/type").innerRefType & import("../../../controller/initialize/callback/type").callbackType & import("react").RefAttributes<RapierRigidBody>>;
|
|
@@ -1,55 +1,37 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useAnimations, useGLTF } from "@react-three/drei";
|
|
3
3
|
import { useFrame, useGraph } from "@react-three/fiber";
|
|
4
|
-
import { CapsuleCollider, RigidBody, euler,
|
|
4
|
+
import { CapsuleCollider, RigidBody, euler, } from "@react-three/rapier";
|
|
5
5
|
import { forwardRef, useContext, useMemo } from "react";
|
|
6
6
|
import * as THREE from "three";
|
|
7
7
|
import { SkeletonUtils } from "three-stdlib";
|
|
8
8
|
import playActions, { subscribeActions } from "../../../animation/actions";
|
|
9
9
|
import Camera from "../../../camera";
|
|
10
10
|
import { GaesupControllerContext } from "../../../controller/context";
|
|
11
|
+
import initCallback from "../../../controller/initialize/callback";
|
|
11
12
|
import { useGltfAndSize } from "../../../hooks/useGaesupGltf";
|
|
12
13
|
import calculation from "../../../physics";
|
|
13
14
|
import { V3 } from "../../../utils";
|
|
14
15
|
import { GaesupWorldContext } from "../../../world/context";
|
|
15
|
-
import { calcCharacterColliderProps } from "../../inner/common/calc";
|
|
16
16
|
import { InnerGroupRef } from "./InnerGroupRef";
|
|
17
|
+
import { setGroundRay } from "./setGroundRay";
|
|
17
18
|
export var RigidBodyRef = forwardRef(function (props, ref) {
|
|
18
19
|
var _a;
|
|
19
20
|
var size = useGltfAndSize({ url: props.url }).size;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
origin: vec3(),
|
|
24
|
-
dir: vec3({ x: 0, y: -1, z: 0 }),
|
|
25
|
-
offset: vec3({ x: 0, y: -1, z: 0 }),
|
|
26
|
-
hit: null,
|
|
27
|
-
parent: null,
|
|
28
|
-
rayCast: null,
|
|
21
|
+
props.groundRay &&
|
|
22
|
+
setGroundRay({
|
|
23
|
+
groundRay: props.groundRay,
|
|
29
24
|
length: 0.5,
|
|
30
|
-
|
|
31
|
-
}, []);
|
|
32
|
-
var _b = useRapier(), rapier = _b.rapier, world = _b.world;
|
|
33
|
-
useFrame(function () {
|
|
34
|
-
var _a;
|
|
35
|
-
groundRay.offset = vec3({
|
|
36
|
-
x: 0,
|
|
37
|
-
y: (collider === null || collider === void 0 ? void 0 : collider.halfHeight) ? -collider.halfHeight : -1,
|
|
38
|
-
z: 0,
|
|
25
|
+
colliderRef: props.colliderRef,
|
|
39
26
|
});
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
groundRay.hit = world.castRay(groundRay.rayCast, groundRay.length, true, undefined, undefined);
|
|
43
|
-
groundRay.parent = (_a = groundRay.hit) === null || _a === void 0 ? void 0 : _a.collider.parent();
|
|
44
|
-
});
|
|
45
|
-
var _c = useGLTF(props.url), scene = _c.scene, animations = _c.animations;
|
|
46
|
-
var _d = useAnimations(animations), actions = _d.actions, animationRef = _d.ref;
|
|
27
|
+
var _b = useGLTF(props.url), scene = _b.scene, animations = _b.animations;
|
|
28
|
+
var _c = useAnimations(animations), actions = _c.actions, animationRef = _c.ref;
|
|
47
29
|
var worldContext = useContext(GaesupWorldContext);
|
|
48
30
|
var controllerContext = useContext(GaesupControllerContext);
|
|
49
31
|
if (props.isActive) {
|
|
50
32
|
subscribeActions({
|
|
51
33
|
type: props.componentType,
|
|
52
|
-
groundRay: groundRay,
|
|
34
|
+
groundRay: props.groundRay,
|
|
53
35
|
animations: animations,
|
|
54
36
|
});
|
|
55
37
|
var cameraProps_1 = {
|
|
@@ -67,7 +49,7 @@ export var RigidBodyRef = forwardRef(function (props, ref) {
|
|
|
67
49
|
innerGroupRef: props.innerGroupRef,
|
|
68
50
|
rigidBodyRef: ref,
|
|
69
51
|
colliderRef: props.colliderRef,
|
|
70
|
-
groundRay: groundRay,
|
|
52
|
+
groundRay: props.groundRay,
|
|
71
53
|
});
|
|
72
54
|
}
|
|
73
55
|
playActions({
|
|
@@ -77,6 +59,11 @@ export var RigidBodyRef = forwardRef(function (props, ref) {
|
|
|
77
59
|
currentAnimation: props.isActive ? undefined : props.currentAnimation,
|
|
78
60
|
isActive: props.isActive,
|
|
79
61
|
});
|
|
62
|
+
initCallback({
|
|
63
|
+
props: props,
|
|
64
|
+
actions: actions,
|
|
65
|
+
componentType: props.componentType,
|
|
66
|
+
});
|
|
80
67
|
var clone = useMemo(function () { return SkeletonUtils.clone(scene); }, [scene]);
|
|
81
68
|
var nodes = useGraph(clone).nodes;
|
|
82
69
|
var objectNode = Object.values(nodes).find(function (node) { return node.type === "Object3D"; });
|
|
@@ -2,6 +2,7 @@ import { Collider } from "@dimforge/rapier3d-compat";
|
|
|
2
2
|
import { CollisionEnterPayload, RigidBodyTypeString } from "@react-three/rapier";
|
|
3
3
|
import { MutableRefObject, RefObject } from "react";
|
|
4
4
|
import * as THREE from "three";
|
|
5
|
+
import { callbackType } from "../../../controller/initialize/callback/type";
|
|
5
6
|
import { groundRayType } from "../../../controller/type";
|
|
6
7
|
import { urlsType } from "../../../world/context/type";
|
|
7
8
|
import { innerRefType, passivePropsType } from "../../passive/type";
|
|
@@ -55,4 +56,5 @@ export type rigidBodyRefType = {
|
|
|
55
56
|
onCollisionEnter?: (e: CollisionEnterPayload) => Promise<void>;
|
|
56
57
|
isActive?: boolean;
|
|
57
58
|
ridingUrl?: string;
|
|
58
|
-
|
|
59
|
+
groundRay?: groundRayType;
|
|
60
|
+
} & passivePropsType & innerRefType & callbackType;
|
|
@@ -33,5 +33,5 @@ export function PassiveCharacter(props) {
|
|
|
33
33
|
cameraTurn: 1,
|
|
34
34
|
cameraPosition: 1,
|
|
35
35
|
},
|
|
36
|
-
}, position: props.position, rotation: props.rotation, currentAnimation: props.currentAnimation }, refs, props, { children: props.children })));
|
|
36
|
+
}, position: props.position, rotation: props.rotation, groundRay: props.groundRay, currentAnimation: props.currentAnimation }, refs, props, { children: props.children })));
|
|
37
37
|
}
|
|
@@ -2,7 +2,7 @@ import { Collider } from "@dimforge/rapier3d-compat";
|
|
|
2
2
|
import { CollisionEnterPayload, RapierRigidBody, RigidBodyTypeString } from "@react-three/rapier";
|
|
3
3
|
import { MutableRefObject } from "react";
|
|
4
4
|
import * as THREE from "three";
|
|
5
|
-
import { controllerOptionsType } from "../../controller/type";
|
|
5
|
+
import { controllerOptionsType, groundRayType } from "../../controller/type";
|
|
6
6
|
import { ridingType } from "../inner/common/type";
|
|
7
7
|
export type componentTypeString = "character" | "vehicle" | "airplane";
|
|
8
8
|
export type innerRefType = {
|
|
@@ -13,6 +13,7 @@ export type innerRefType = {
|
|
|
13
13
|
};
|
|
14
14
|
export type passivePropsType = {
|
|
15
15
|
children?: React.ReactNode;
|
|
16
|
+
groundRay?: groundRayType;
|
|
16
17
|
url: string;
|
|
17
18
|
ridingUrl?: string;
|
|
18
19
|
wheelUrl?: string;
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import { AnimationAction } from "three";
|
|
2
|
+
import { rigidBodyRefType } from "../../../component/inner/common/type";
|
|
3
|
+
import { componentTypeString } from "../../../component/passive/type";
|
|
3
4
|
import { animationTagType } from "../../type";
|
|
4
|
-
export default function initCallback({
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
export default function initCallback({ props, actions, componentType, }: {
|
|
6
|
+
props: rigidBodyRefType;
|
|
7
|
+
actions: {
|
|
8
|
+
[x: string]: AnimationAction;
|
|
9
|
+
};
|
|
10
|
+
componentType: componentTypeString;
|
|
7
11
|
}): {
|
|
8
12
|
subscribe: ({ tag, condition, action, animationName, key, }: import("../../../world/context/type").animationAtomType) => void;
|
|
9
13
|
playAnimation: (tag: keyof animationTagType, key: string) => void;
|
|
@@ -9,24 +9,22 @@ var __assign = (this && this.__assign) || function () {
|
|
|
9
9
|
};
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
11
|
};
|
|
12
|
-
import {
|
|
12
|
+
import { useFrame } from "@react-three/fiber";
|
|
13
|
+
import { useContext, useEffect } from "react";
|
|
13
14
|
import { useGaesupAnimation } from "../../../hooks/useGaesupAnimation";
|
|
14
15
|
import { GaesupWorldContext, GaesupWorldDispatchContext, } from "../../../world/context";
|
|
15
16
|
export default function initCallback(_a) {
|
|
16
|
-
var
|
|
17
|
-
// props,
|
|
18
|
-
animationResult = _a.animationResult, type = _a.type;
|
|
19
|
-
var actions = animationResult.actions;
|
|
17
|
+
var props = _a.props, actions = _a.actions, componentType = _a.componentType;
|
|
20
18
|
var animationState = useContext(GaesupWorldContext).animationState;
|
|
21
19
|
var dispatch = useContext(GaesupWorldDispatchContext);
|
|
22
|
-
var store = useGaesupAnimation({ type:
|
|
20
|
+
var store = useGaesupAnimation({ type: componentType }).store;
|
|
23
21
|
var _b = useContext(GaesupWorldContext), activeState = _b.activeState, states = _b.states, control = _b.control;
|
|
24
|
-
var subscribe = useGaesupAnimation({ type:
|
|
22
|
+
var subscribe = useGaesupAnimation({ type: componentType }).subscribe;
|
|
25
23
|
var playAnimation = function (tag, key) {
|
|
26
24
|
if (!(key in control))
|
|
27
25
|
return;
|
|
28
|
-
if (control[key]) {
|
|
29
|
-
animationState[
|
|
26
|
+
if (control[key] && animationState[componentType]) {
|
|
27
|
+
animationState[componentType].current = tag;
|
|
30
28
|
var currentAnimation = store[tag];
|
|
31
29
|
if (currentAnimation === null || currentAnimation === void 0 ? void 0 : currentAnimation.action) {
|
|
32
30
|
currentAnimation.action();
|
|
@@ -39,39 +37,30 @@ export default function initCallback(_a) {
|
|
|
39
37
|
});
|
|
40
38
|
}
|
|
41
39
|
};
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
// props.onAnimate({
|
|
67
|
-
// ...controllerProp,
|
|
68
|
-
// ...prop,
|
|
69
|
-
// actions,
|
|
70
|
-
// animationState,
|
|
71
|
-
// playAnimation,
|
|
72
|
-
// });
|
|
73
|
-
// }
|
|
74
|
-
// });
|
|
40
|
+
var controllerProp = {
|
|
41
|
+
activeState: activeState,
|
|
42
|
+
control: control,
|
|
43
|
+
states: states,
|
|
44
|
+
subscribe: subscribe,
|
|
45
|
+
};
|
|
46
|
+
useEffect(function () {
|
|
47
|
+
if (props.onReady) {
|
|
48
|
+
props.onReady(controllerProp);
|
|
49
|
+
}
|
|
50
|
+
return function () {
|
|
51
|
+
if (props.onDestory) {
|
|
52
|
+
props.onDestory(controllerProp);
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
}, []);
|
|
56
|
+
useFrame(function (prop) {
|
|
57
|
+
if (props.onFrame) {
|
|
58
|
+
props.onFrame(__assign(__assign({}, controllerProp), prop));
|
|
59
|
+
}
|
|
60
|
+
if (props.onAnimate) {
|
|
61
|
+
props.onAnimate(__assign(__assign(__assign({}, controllerProp), prop), { actions: actions, animationState: animationState, playAnimation: playAnimation }));
|
|
62
|
+
}
|
|
63
|
+
});
|
|
75
64
|
return {
|
|
76
65
|
subscribe: subscribe,
|
|
77
66
|
playAnimation: playAnimation,
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
import { RootState } from "@react-three/fiber";
|
|
2
2
|
import * as THREE from "three";
|
|
3
|
-
import { cameraRayType } from "../../../camera/type";
|
|
4
3
|
import { activeStateType, animationAtomType, animationStateType, keyControlType, statesType } from "../../../world/context/type";
|
|
5
|
-
import { actionsType
|
|
4
|
+
import { actionsType } from "../../type";
|
|
6
5
|
export type callbackPropType = {
|
|
7
6
|
activeState: activeStateType;
|
|
8
7
|
states: statesType;
|
|
9
|
-
groundRay: groundRayType;
|
|
10
|
-
cameraRay: cameraRayType;
|
|
11
8
|
control: keyControlType;
|
|
12
9
|
subscribe: (props: animationAtomType) => void;
|
|
13
10
|
};
|
|
@@ -6,20 +6,17 @@ export default function checkOnTheGround(prop) {
|
|
|
6
6
|
states.isOnTheGround = false;
|
|
7
7
|
}
|
|
8
8
|
if (groundRay.hit) {
|
|
9
|
-
|
|
9
|
+
var MAX = groundRay.length * 2;
|
|
10
|
+
var MIN = groundRay.length * 0.8;
|
|
11
|
+
if (groundRay.hit.toi >= MAX) {
|
|
10
12
|
states.isFalling = true;
|
|
11
|
-
states.isLanding = false;
|
|
12
13
|
states.isOnTheGround = false;
|
|
13
14
|
}
|
|
14
|
-
else if (
|
|
15
|
-
|
|
16
|
-
states.isLanding = true;
|
|
17
|
-
states.isFalling = false;
|
|
18
|
-
states.isOnTheGround = false;
|
|
15
|
+
else if (MIN <= groundRay.hit.toi && groundRay.hit.toi < MAX) {
|
|
16
|
+
states.isFalling = true;
|
|
19
17
|
}
|
|
20
|
-
else {
|
|
18
|
+
else if (groundRay.hit.toi < MIN) {
|
|
21
19
|
states.isFalling = false;
|
|
22
|
-
states.isLanding = false;
|
|
23
20
|
states.isOnTheGround = true;
|
|
24
21
|
}
|
|
25
22
|
}
|
|
@@ -5,16 +5,18 @@ export default function moving(prop) {
|
|
|
5
5
|
states.isMoving = forward || backward || leftward || rightward;
|
|
6
6
|
states.isNotMoving = !states.isMoving;
|
|
7
7
|
states.isRunning = shift && states.isMoving;
|
|
8
|
+
states.isJumping = space;
|
|
8
9
|
}
|
|
9
10
|
else if (mode.controller === "joystick") {
|
|
10
11
|
states.isMoving = joystick.joyStickOrigin.isOn;
|
|
11
12
|
states.isNotMoving = !joystick.joyStickOrigin.isOn;
|
|
12
13
|
states.isRunning = shift && states.isMoving;
|
|
14
|
+
states.isJumping = space;
|
|
13
15
|
}
|
|
14
16
|
else if (mode.controller === "clicker") {
|
|
15
17
|
states.isMoving = clicker.isOn;
|
|
16
18
|
states.isNotMoving = !clicker.isOn;
|
|
17
19
|
states.isRunning = (shift || clicker.isRun) && states.isMoving;
|
|
20
|
+
states.isJumping = space;
|
|
18
21
|
}
|
|
19
|
-
states.isJumping = space;
|
|
20
22
|
}
|
|
@@ -45,15 +45,23 @@ export function MiniMap(props) {
|
|
|
45
45
|
? "translate(-50%, 50%) rotate(180deg) "
|
|
46
46
|
: "translate(-50%, 50%) rotate(-".concat((activeState.euler.y * 180) / Math.PI + 180, "deg) ") }, directionStyle), children: "S" }), _jsx("div", { className: "north direction", style: __assign({ transform: props.blockRotate || mode.control === "normal"
|
|
47
47
|
? "translate(-50%, -50%) rotate(180deg) "
|
|
48
|
-
: "translate(-50%, -50%) rotate(-".concat((activeState.euler.y * 180) / Math.PI + 180, "deg) ") }, directionStyle), children: "N" }),
|
|
48
|
+
: "translate(-50%, -50%) rotate(-".concat((activeState.euler.y * 180) / Math.PI + 180, "deg) ") }, directionStyle), children: "N" }), Object.values(minimap.props).map(function (_a, key) {
|
|
49
49
|
var center = _a.center, size = _a.size, text = _a.text;
|
|
50
50
|
var X = (center.x - activeState.position.x) *
|
|
51
|
-
(props.angle ?
|
|
51
|
+
(props.angle ? Math.sin(props.angle) : 1) *
|
|
52
52
|
scale;
|
|
53
53
|
var Z = (center.z - activeState.position.z) *
|
|
54
54
|
(props.angle ? -Math.cos(props.angle) : 1) *
|
|
55
55
|
scale;
|
|
56
|
-
return (_jsxs("div", { children: [_jsx("div", { className: "minimapObject", style: __assign({ width: "".concat(size.x * scale, "rem"), height: "".concat(size.z * scale, "rem"), top: "50%", left: "50%", transform: "translate(-50.1%, -50.1%) translate(".concat(-X, "rem, ").concat(-Z, "rem)
|
|
56
|
+
return (_jsxs("div", { children: [_jsx("div", { className: "minimapObject", style: __assign({ width: "".concat(size.x * scale, "rem"), height: "".concat(size.z * scale, "rem"), top: "50%", left: "50%", transform: "translate(-50.1%, -50.1%) translate(".concat(-X, "rem, ").concat(-Z, "rem) rotate(").concat((Math.PI * 3) / 2 + props.angle || 0, "rad)"), transformOrigin: "50% 50%", zIndex: 1 + key }, objectStyle) }, key), _jsx("div", { className: "imageObject", style: {
|
|
57
|
+
width: "".concat(size.x * scale, "rem"),
|
|
58
|
+
height: "".concat(size.z * scale, "rem"),
|
|
59
|
+
top: "50%",
|
|
60
|
+
left: "50%",
|
|
61
|
+
transform: "translate(-50.1%, -50.1%) translate(".concat(-X, "rem, ").concat(-Z, "rem) rotate(").concat((Math.PI * 3) / 2 + props.angle || 0, "rad)"),
|
|
62
|
+
transformOrigin: "50% 50%",
|
|
63
|
+
zIndex: 1 + key,
|
|
64
|
+
} }, key), _jsx("div", { className: "textObject", style: {
|
|
57
65
|
width: "".concat(size.x * scale, "rem"),
|
|
58
66
|
height: "".concat(size.z * scale, "rem"),
|
|
59
67
|
top: "50.1%",
|
|
@@ -188,6 +188,7 @@
|
|
|
188
188
|
text-align: center;
|
|
189
189
|
border-radius: 2px;
|
|
190
190
|
background: rgba(0, 0, 0, 0.3);
|
|
191
|
+
|
|
191
192
|
/* border: 2px solid rgba(88, 88, 88, 0.5); */
|
|
192
193
|
}
|
|
193
194
|
|
|
@@ -198,9 +199,11 @@
|
|
|
198
199
|
align-items: center;
|
|
199
200
|
justify-content: center;
|
|
200
201
|
text-align: center;
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
202
|
+
background:
|
|
203
|
+
linear-gradient(to bottom, transparent 95%, rgba(0, 0, 0, 0.2) 20%) 0 0 /
|
|
204
|
+
100% 40px repeat-y,
|
|
205
|
+
linear-gradient(to right, transparent 38px, rgba(0, 0, 0, 0.2) 38px) 0 0 /
|
|
206
|
+
40px 100% repeat-x transparent;
|
|
204
207
|
}
|
|
205
208
|
|
|
206
209
|
.textObject {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gaesup-world",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -11,9 +11,11 @@
|
|
|
11
11
|
"@react-icons/all-files": "^4.1.0",
|
|
12
12
|
"@react-three/drei": "9.105.4",
|
|
13
13
|
"@react-three/fiber": "8.16.2",
|
|
14
|
+
"@react-three/postprocessing": "^2.16.2",
|
|
14
15
|
"@react-three/rapier": "^1.3.1",
|
|
15
16
|
"@types/three": "^0.163.0",
|
|
16
17
|
"gh-pages": "^6.1.1",
|
|
18
|
+
"jotai": "^2.8.0",
|
|
17
19
|
"leva": "0.9.35",
|
|
18
20
|
"lodash": "^4.17.21",
|
|
19
21
|
"node-fetch": "3.3.2",
|
|
@@ -47,7 +49,7 @@
|
|
|
47
49
|
"description": "Web 3D Character Controller and World Platform Library",
|
|
48
50
|
"repository": {
|
|
49
51
|
"type": "git",
|
|
50
|
-
"url": "git+https://github.com/jigglypop
|
|
52
|
+
"url": "git+https://github.com/jigglypop/../../../src.git"
|
|
51
53
|
},
|
|
52
54
|
"keywords": [
|
|
53
55
|
"three.js",
|
|
@@ -60,7 +62,7 @@
|
|
|
60
62
|
"author": "jigglypop",
|
|
61
63
|
"license": "MIT",
|
|
62
64
|
"bugs": {
|
|
63
|
-
"url": "https://github.com/jigglypop/
|
|
65
|
+
"url": "https://github.com/jigglypop/../../../src/issues"
|
|
64
66
|
},
|
|
65
67
|
"scripts": {
|
|
66
68
|
"dev": "vite",
|