gaesup-world 0.8.3 → 0.8.5
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 +2 -2
- package/dist/gaesup/component/active/character/index.js +1 -1
- package/dist/gaesup/component/inner/character/type.d.ts +2 -1
- package/dist/gaesup/component/inner/common/InnerGroupRef.d.ts +1 -0
- package/dist/gaesup/component/inner/common/RigidbodyRef.d.ts +3 -2
- package/dist/gaesup/component/inner/common/RigidbodyRef.js +5 -1
- package/dist/gaesup/component/inner/common/partsGroupRef.d.ts +7 -0
- package/dist/gaesup/component/inner/common/partsGroupRef.js +31 -0
- package/dist/gaesup/component/inner/common/type.d.ts +5 -3
- package/dist/gaesup/component/passive/type.d.ts +2 -2
- package/dist/gaesup/controller/index.js +1 -1
- package/dist/gaesup/controller/type.d.ts +3 -0
- package/dist/gaesup/gaesupProps/index.js +4 -12
- package/dist/gaesup/hooks/useClicker/index.d.ts +0 -1
- package/dist/gaesup/hooks/useClicker/index.js +3 -31
- package/dist/gaesup/hooks/useMovePoint/index.js +5 -23
- package/dist/gaesup/hooks/useTeleport/index.js +7 -4
- package/dist/gaesup/physics/character/direction.d.ts +3 -20
- package/dist/gaesup/physics/character/direction.js +7 -7
- package/dist/gaesup/physics/character/impulse.js +1 -18
- package/dist/gaesup/physics/character/index.js +2 -0
- package/dist/gaesup/physics/character/queue.d.ts +2 -0
- package/dist/gaesup/physics/character/queue.js +48 -0
- package/dist/gaesup/physics/character/stop.js +1 -11
- package/dist/gaesup/tools/clicker/index.js +17 -2
- package/dist/gaesup/tools/gamepad/style.css +0 -1
- package/dist/gaesup/tools/rideable/index.js +0 -1
- package/dist/gaesup/tools/rideable/type.d.ts +2 -2
- package/dist/gaesup/world/context/index.js +5 -0
- package/dist/gaesup/world/context/type.d.ts +17 -2
- package/dist/index.js +0 -1
- package/package.json +1 -1
- package/dist/gaesup/camera/detector/index.d.ts +0 -2
- package/dist/gaesup/camera/detector/index.js +0 -28
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { V3 } from "../../utils/vector";
|
|
2
2
|
export var makeNormalCameraPosition = function (activeState, cameraOption) {
|
|
3
|
-
var YDistance = cameraOption.YDistance, ZDistance = cameraOption.ZDistance;
|
|
3
|
+
var XDistance = cameraOption.XDistance, YDistance = cameraOption.YDistance, ZDistance = cameraOption.ZDistance;
|
|
4
4
|
var cameraPosition = activeState.position
|
|
5
5
|
.clone()
|
|
6
|
-
.add(V3(
|
|
6
|
+
.add(V3(XDistance, YDistance, ZDistance));
|
|
7
7
|
return cameraPosition;
|
|
8
8
|
};
|
|
9
9
|
export default function normal(prop) {
|
|
@@ -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 children = _a.children, 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, groundRay: props.groundRay, onAnimate: props.onAnimate, onFrame: props.onFrame, onReady: props.onReady, onDestory: props.onDestory }, refs, { children: 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, rigidBodyProps: props.rigidBodyProps, parts: props.parts }, refs, { children: children })));
|
|
17
17
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { callbackType } from "../../../controller/initialize/callback/type";
|
|
2
|
-
import { groundRayType } from "../../../controller/type";
|
|
2
|
+
import { groundRayType, partsType } from "../../../controller/type";
|
|
3
3
|
import { passiveCharacterPropsType } from "../../passive/character/type";
|
|
4
4
|
import { componentTypeString, innerRefType } from "../../passive/type";
|
|
5
5
|
export type characterInnerType = {
|
|
6
6
|
componentType: componentTypeString;
|
|
7
7
|
isActive?: boolean;
|
|
8
8
|
groundRay: groundRayType;
|
|
9
|
+
parts?: partsType;
|
|
9
10
|
} & passiveCharacterPropsType & innerRefType & callbackType;
|
|
@@ -10,4 +10,5 @@ export declare const InnerGroupRef: import("react").ForwardRefExoticComponent<{
|
|
|
10
10
|
isActive?: boolean;
|
|
11
11
|
ridingUrl?: string;
|
|
12
12
|
offset?: THREE.Vector3;
|
|
13
|
+
parts?: import("../../../controller/type").partsType;
|
|
13
14
|
} & import("./type").ridingType & import("react").RefAttributes<THREE.Group<THREE.Object3DEventMap>>>;
|
|
@@ -9,7 +9,8 @@ export declare const RigidBodyRef: import("react").ForwardRefExoticComponent<{
|
|
|
9
9
|
isActive?: boolean;
|
|
10
10
|
ridingUrl?: string;
|
|
11
11
|
groundRay?: import("../../../controller/type").groundRayType;
|
|
12
|
-
rigidBodyProps?:
|
|
12
|
+
rigidBodyProps?: import("@react-three/rapier").RigidBodyProps;
|
|
13
|
+
parts?: import("../../../controller/type").partsType;
|
|
13
14
|
} & {
|
|
14
15
|
children?: import("react").ReactNode;
|
|
15
16
|
groundRay?: import("../../../controller/type").groundRayType;
|
|
@@ -29,7 +30,7 @@ export declare const RigidBodyRef: import("react").ForwardRefExoticComponent<{
|
|
|
29
30
|
userData?: {
|
|
30
31
|
intangible: boolean;
|
|
31
32
|
};
|
|
32
|
-
rigidBodyProps?:
|
|
33
|
+
rigidBodyProps?: import("@react-three/rapier").RigidBodyProps;
|
|
33
34
|
outerGroupProps?: THREE.Group<THREE.Object3DEventMap>;
|
|
34
35
|
innerGroupProps?: THREE.Group<THREE.Object3DEventMap>;
|
|
35
36
|
} & import("./type").ridingType & import("../../passive/type").innerRefType & import("../../../controller/initialize/callback/type").callbackType & import("react").RefAttributes<RapierRigidBody>>;
|
|
@@ -25,6 +25,7 @@ import calculation from "../../../physics";
|
|
|
25
25
|
import { V3 } from "../../../utils";
|
|
26
26
|
import { GaesupWorldContext } from "../../../world/context";
|
|
27
27
|
import { InnerGroupRef } from "./InnerGroupRef";
|
|
28
|
+
import { PartsGroupRef } from "./partsGroupRef";
|
|
28
29
|
import { setGroundRay } from "./setGroundRay";
|
|
29
30
|
export var RigidBodyRef = forwardRef(function (props, ref) {
|
|
30
31
|
var _a;
|
|
@@ -85,5 +86,8 @@ export var RigidBodyRef = forwardRef(function (props, ref) {
|
|
|
85
86
|
});
|
|
86
87
|
return (_jsxs(RigidBody, __assign({ colliders: false, ref: ref, name: props.name, rotation: euler()
|
|
87
88
|
.set(0, ((_a = props.rotation) === null || _a === void 0 ? void 0 : _a.clone().y) || 0, 0)
|
|
88
|
-
.clone(), userData: props.userData, type: props.rigidbodyType || (props.isActive ? "dynamic" : "fixed"), sensor: props.sensor, onIntersectionEnter: props.onIntersectionEnter, onCollisionEnter: props.onCollisionEnter }, props.rigidBodyProps, { children: [_jsx(CapsuleCollider, { ref: props.colliderRef, args: [(size.y / 2 - size.x) * 1.2, size.x * 1.2], position: [0, (size.y / 2 + size.x / 2) * 1.2, 0] }),
|
|
89
|
+
.clone(), userData: props.userData, type: props.rigidbodyType || (props.isActive ? "dynamic" : "fixed"), sensor: props.sensor, onIntersectionEnter: props.onIntersectionEnter, onCollisionEnter: props.onCollisionEnter }, props.rigidBodyProps, { children: [_jsx(CapsuleCollider, { ref: props.colliderRef, args: [(size.y / 2 - size.x) * 1.2, size.x * 1.2], position: [0, (size.y / 2 + size.x / 2) * 1.2, 0] }), _jsxs(InnerGroupRef, { objectNode: objectNode, animationRef: animationRef, nodes: nodes, ref: props.innerGroupRef, isActive: props.isActive, isRiderOn: props.isRiderOn, enableRiding: props.enableRiding, ridingUrl: props.ridingUrl, offset: props.offset, parts: props.parts, children: [props.children, props.parts &&
|
|
90
|
+
props.parts.map(function (url, key) {
|
|
91
|
+
return (_jsx(PartsGroupRef, { url: url, isActive: props.isActive, componentType: props.componentType, currentAnimation: props.currentAnimation }, key + url));
|
|
92
|
+
})] })] })));
|
|
89
93
|
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { componentTypeString } from "../../passive/type";
|
|
2
|
+
export declare const PartsGroupRef: ({ url, isActive, componentType, currentAnimation, }: {
|
|
3
|
+
url: string;
|
|
4
|
+
isActive: boolean;
|
|
5
|
+
componentType: componentTypeString;
|
|
6
|
+
currentAnimation: string;
|
|
7
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useAnimations, useGLTF } from "@react-three/drei";
|
|
3
|
+
import { useGraph } from "@react-three/fiber";
|
|
4
|
+
import { useMemo } from "react";
|
|
5
|
+
import * as THREE from "three";
|
|
6
|
+
import { SkeletonUtils } from "three-stdlib";
|
|
7
|
+
import playActions from "../../../animation/actions";
|
|
8
|
+
export var PartsGroupRef = function (_a) {
|
|
9
|
+
var url = _a.url, isActive = _a.isActive, componentType = _a.componentType, currentAnimation = _a.currentAnimation;
|
|
10
|
+
var _b = useGLTF(url), scene = _b.scene, animations = _b.animations;
|
|
11
|
+
var clone = useMemo(function () { return SkeletonUtils.clone(scene); }, [scene]);
|
|
12
|
+
var _c = useAnimations(animations), actions = _c.actions, ref = _c.ref;
|
|
13
|
+
var nodes = useGraph(clone).nodes;
|
|
14
|
+
var objectNode = Object.values(nodes).find(function (node) { return node.type === "Object3D"; });
|
|
15
|
+
playActions({
|
|
16
|
+
type: componentType,
|
|
17
|
+
actions: actions,
|
|
18
|
+
animationRef: ref,
|
|
19
|
+
currentAnimation: isActive ? undefined : currentAnimation,
|
|
20
|
+
isActive: isActive,
|
|
21
|
+
});
|
|
22
|
+
return (_jsxs(_Fragment, { children: [_jsx("primitive", { object: objectNode, visible: false, receiveShadow: true, castShadow: true, ref: ref }), Object.keys(nodes).map(function (name, key) {
|
|
23
|
+
var node = nodes[name];
|
|
24
|
+
if (node instanceof THREE.SkinnedMesh) {
|
|
25
|
+
return (_jsx("skinnedMesh", { castShadow: true, receiveShadow: true, material: node.material, geometry: node.geometry, skeleton: node.skeleton }, key));
|
|
26
|
+
}
|
|
27
|
+
else if (node instanceof THREE.Mesh) {
|
|
28
|
+
return (_jsx("mesh", { castShadow: true, receiveShadow: true, material: node.material, geometry: node.geometry }, key));
|
|
29
|
+
}
|
|
30
|
+
})] }));
|
|
31
|
+
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Collider } from "@dimforge/rapier3d-compat";
|
|
2
|
-
import {
|
|
2
|
+
import { RigidBodyProps, RigidBodyTypeString } from "@react-three/rapier";
|
|
3
3
|
import { MutableRefObject, RefObject } from "react";
|
|
4
4
|
import * as THREE from "three";
|
|
5
5
|
import { callbackType } from "../../../controller/initialize/callback/type";
|
|
6
|
-
import { groundRayType } from "../../../controller/type";
|
|
6
|
+
import { groundRayType, partsType } from "../../../controller/type";
|
|
7
7
|
import { urlsType } from "../../../world/context/type";
|
|
8
8
|
import { innerRefType, passivePropsType } from "../../passive/type";
|
|
9
9
|
export type characterColliderType = {
|
|
@@ -22,6 +22,7 @@ export type InnerGroupRefType = {
|
|
|
22
22
|
isActive?: boolean;
|
|
23
23
|
ridingUrl?: string;
|
|
24
24
|
offset?: THREE.Vector3;
|
|
25
|
+
parts?: partsType;
|
|
25
26
|
} & ridingType;
|
|
26
27
|
export type ridingType = {
|
|
27
28
|
isRiderOn?: boolean;
|
|
@@ -55,5 +56,6 @@ export type rigidBodyRefType = {
|
|
|
55
56
|
isActive?: boolean;
|
|
56
57
|
ridingUrl?: string;
|
|
57
58
|
groundRay?: groundRayType;
|
|
58
|
-
rigidBodyProps?:
|
|
59
|
+
rigidBodyProps?: RigidBodyProps;
|
|
60
|
+
parts?: partsType;
|
|
59
61
|
} & passivePropsType & innerRefType & callbackType;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Collider } from "@dimforge/rapier3d-compat";
|
|
2
|
-
import { CollisionEnterPayload, RapierRigidBody, RigidBodyTypeString } from "@react-three/rapier";
|
|
2
|
+
import { CollisionEnterPayload, RapierRigidBody, RigidBodyProps, RigidBodyTypeString } from "@react-three/rapier";
|
|
3
3
|
import { MutableRefObject } from "react";
|
|
4
4
|
import * as THREE from "three";
|
|
5
5
|
import { controllerOptionsType, groundRayType } from "../../controller/type";
|
|
@@ -30,7 +30,7 @@ export type passivePropsType = {
|
|
|
30
30
|
userData?: {
|
|
31
31
|
intangible: boolean;
|
|
32
32
|
};
|
|
33
|
-
rigidBodyProps?:
|
|
33
|
+
rigidBodyProps?: RigidBodyProps;
|
|
34
34
|
outerGroupProps?: THREE.Group;
|
|
35
35
|
innerGroupProps?: THREE.Group;
|
|
36
36
|
} & ridingType;
|
|
@@ -65,7 +65,7 @@ export function GaesupControllerInner(props) {
|
|
|
65
65
|
}, []);
|
|
66
66
|
var prop = __assign(__assign(__assign(__assign({}, initControllerProps({
|
|
67
67
|
refs: refs,
|
|
68
|
-
})), { children: props.children, groupProps: props.groupProps, controllerOptions: gaesupControl.value.controllerOptions }), gaesupControl.value.callbacks), refs);
|
|
68
|
+
})), { children: props.children, groupProps: props.groupProps, rigidBodyProps: props.rigidBodyProps, controllerOptions: gaesupControl.value.controllerOptions, parts: props.parts }), gaesupControl.value.callbacks), refs);
|
|
69
69
|
initDebug({
|
|
70
70
|
controllerContext: gaesupControl.value,
|
|
71
71
|
controllerDispatch: gaesupControl.dispatch,
|
|
@@ -54,6 +54,7 @@ export type controllerInnerType = {
|
|
|
54
54
|
cameraRay: cameraRayType;
|
|
55
55
|
keyControl: keyControlType;
|
|
56
56
|
controllerOptions: controllerOptionsType;
|
|
57
|
+
parts?: partsType;
|
|
57
58
|
} & controllerOtherPropType & refsType & callbackType;
|
|
58
59
|
export type animationTagType = {
|
|
59
60
|
idle: string;
|
|
@@ -89,6 +90,8 @@ export interface controllerOtherPropType extends RigidBodyProps {
|
|
|
89
90
|
rigidBodyProps?: RigidBodyProps;
|
|
90
91
|
debug?: boolean;
|
|
91
92
|
}
|
|
93
|
+
export type partsType = string[];
|
|
92
94
|
export type controllerType = controllerOtherPropType & urlsType & Partial<gaesupControllerContextPropType> & callbackType & {
|
|
93
95
|
controllerOptions?: controllerOptionsType;
|
|
96
|
+
parts?: partsType;
|
|
94
97
|
};
|
|
@@ -18,10 +18,10 @@ import { GaesupWorldContext, GaesupWorldDispatchContext, } from "../world/contex
|
|
|
18
18
|
export function GaeSupProps(_a) {
|
|
19
19
|
var _b = _a.type, type = _b === void 0 ? "normal" : _b, text = _a.text, position = _a.position, children = _a.children;
|
|
20
20
|
var groupRef = useRef(null);
|
|
21
|
-
var _c = useContext(GaesupWorldContext), minimap = _c.minimap, clickerOption = _c.clickerOption;
|
|
21
|
+
var _c = useContext(GaesupWorldContext), minimap = _c.minimap, activeState = _c.activeState, clickerOption = _c.clickerOption;
|
|
22
22
|
var dispatch = useContext(GaesupWorldDispatchContext);
|
|
23
23
|
// clicker
|
|
24
|
-
var
|
|
24
|
+
var moveClicker = useClicker().moveClicker;
|
|
25
25
|
useEffect(function () {
|
|
26
26
|
if (groupRef.current) {
|
|
27
27
|
var box = new THREE.Box3().setFromObject(groupRef.current);
|
|
@@ -43,16 +43,8 @@ export function GaeSupProps(_a) {
|
|
|
43
43
|
}
|
|
44
44
|
}, []);
|
|
45
45
|
return (_jsx("group", { ref: groupRef, position: position, onPointerDown: function (e) {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
// You may optionally capture the target
|
|
49
|
-
e.target.setPointerCapture(e.pointerId);
|
|
46
|
+
if (e.srcElement instanceof HTMLDivElement)
|
|
47
|
+
return;
|
|
50
48
|
moveClicker(e, false, type);
|
|
51
|
-
}, onPointerUp: function (e) {
|
|
52
|
-
e.stopPropagation();
|
|
53
|
-
// Optionally release capture
|
|
54
|
-
e.target.releasePointerCapture(e.pointerId);
|
|
55
|
-
}, onDoubleClick: function (e) {
|
|
56
|
-
moveDoubleClicker(e, true, type);
|
|
57
49
|
}, children: children }));
|
|
58
50
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { ThreeEvent } from "@react-three/fiber";
|
|
2
2
|
export declare function useClicker(): {
|
|
3
3
|
moveClicker: (e: ThreeEvent<MouseEvent>, isRun: boolean, type: "normal" | "ground") => void;
|
|
4
|
-
moveDoubleClicker: (e: ThreeEvent<MouseEvent>, isRun: boolean, type: "normal" | "ground") => void;
|
|
5
4
|
};
|
|
@@ -1,37 +1,20 @@
|
|
|
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
1
|
import { useContext } from "react";
|
|
13
|
-
import { V3
|
|
2
|
+
import { V3 } from "../../utils";
|
|
14
3
|
import { GaesupWorldContext, GaesupWorldDispatchContext, } from "../../world/context";
|
|
15
4
|
export function useClicker() {
|
|
16
|
-
var _a = useContext(GaesupWorldContext), activeState = _a.activeState, mode = _a.mode
|
|
5
|
+
var _a = useContext(GaesupWorldContext), activeState = _a.activeState, mode = _a.mode;
|
|
17
6
|
var dispatch = useContext(GaesupWorldDispatchContext);
|
|
18
7
|
var moveClicker = function (e, isRun, type) {
|
|
19
8
|
if (mode.controller !== "clicker" || type !== "ground")
|
|
20
9
|
return;
|
|
21
10
|
var u = activeState.position;
|
|
22
11
|
var v = V3(e.point.x, e.point.y, e.point.z);
|
|
23
|
-
var norm = calcNorm(u, v, false);
|
|
24
|
-
if (norm < 2)
|
|
25
|
-
return;
|
|
26
|
-
var gap = calcNorm(v, clicker.point, true);
|
|
27
|
-
if (gap < 1)
|
|
28
|
-
return;
|
|
29
12
|
var newAngle = Math.atan2(v.z - u.z, v.x - u.x);
|
|
30
13
|
dispatch({
|
|
31
14
|
type: "update",
|
|
32
15
|
payload: {
|
|
33
16
|
clicker: {
|
|
34
|
-
point: v,
|
|
17
|
+
point: V3(v.x, 0, v.z),
|
|
35
18
|
angle: newAngle,
|
|
36
19
|
isOn: true,
|
|
37
20
|
isRun: isRun,
|
|
@@ -39,18 +22,7 @@ export function useClicker() {
|
|
|
39
22
|
},
|
|
40
23
|
});
|
|
41
24
|
};
|
|
42
|
-
var moveDoubleClicker = function (e, isRun, type) {
|
|
43
|
-
if (!clicker.isOn || !clickerOption.isRun)
|
|
44
|
-
return;
|
|
45
|
-
dispatch({
|
|
46
|
-
type: "update",
|
|
47
|
-
payload: {
|
|
48
|
-
clicker: __assign(__assign({}, clicker), { isRun: isRun }),
|
|
49
|
-
},
|
|
50
|
-
});
|
|
51
|
-
};
|
|
52
25
|
return {
|
|
53
26
|
moveClicker: moveClicker,
|
|
54
|
-
moveDoubleClicker: moveDoubleClicker,
|
|
55
27
|
};
|
|
56
28
|
}
|
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { vec3 } from "@react-three/rapier";
|
|
2
|
+
import { useContext } from "react";
|
|
2
3
|
import { V3 } from "../../utils";
|
|
3
4
|
import { GaesupWorldContext, GaesupWorldDispatchContext, } from "../../world/context";
|
|
4
5
|
export function useMovePoint() {
|
|
5
6
|
var _a = useContext(GaesupWorldContext), activeState = _a.activeState, clicker = _a.clicker;
|
|
6
7
|
var dispatch = useContext(GaesupWorldDispatchContext);
|
|
7
8
|
var move = function (position, isRun) {
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
Math.pow(position.x - originPoint.x, 2));
|
|
12
|
-
if (norm < 2)
|
|
13
|
-
return;
|
|
9
|
+
var u = activeState.position;
|
|
10
|
+
var v = vec3(position);
|
|
11
|
+
var newAngle = Math.atan2(v.z - u.z, v.x - u.x);
|
|
14
12
|
dispatch({
|
|
15
13
|
type: "update",
|
|
16
14
|
payload: {
|
|
@@ -23,22 +21,6 @@ export function useMovePoint() {
|
|
|
23
21
|
},
|
|
24
22
|
});
|
|
25
23
|
};
|
|
26
|
-
// 거리 계산
|
|
27
|
-
useEffect(function () {
|
|
28
|
-
var originPoint = activeState.position;
|
|
29
|
-
var newPosition = clicker.point;
|
|
30
|
-
var norm = Math.sqrt(Math.pow(newPosition.z - originPoint.z, 2) +
|
|
31
|
-
Math.pow(newPosition.x - originPoint.x, 2));
|
|
32
|
-
if (norm < 1) {
|
|
33
|
-
clicker.isOn = false;
|
|
34
|
-
dispatch({
|
|
35
|
-
type: "update",
|
|
36
|
-
payload: {
|
|
37
|
-
clicker: clicker,
|
|
38
|
-
},
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
}, [activeState.position, clicker.point]);
|
|
42
24
|
return {
|
|
43
25
|
move: move,
|
|
44
26
|
};
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { useContext } from "react";
|
|
2
2
|
import { GaesupWorldContext } from "../../world/context";
|
|
3
3
|
export function useTeleport() {
|
|
4
|
-
var
|
|
4
|
+
var worldContext = useContext(GaesupWorldContext);
|
|
5
5
|
var Teleport = function (position) {
|
|
6
|
-
var _a, _b;
|
|
7
|
-
if (
|
|
8
|
-
(
|
|
6
|
+
var _a, _b, _c;
|
|
7
|
+
if (worldContext &&
|
|
8
|
+
(worldContext === null || worldContext === void 0 ? void 0 : worldContext.refs) &&
|
|
9
|
+
((_a = worldContext === null || worldContext === void 0 ? void 0 : worldContext.refs) === null || _a === void 0 ? void 0 : _a.rigidBodyRef) &&
|
|
10
|
+
((_c = (_b = worldContext === null || worldContext === void 0 ? void 0 : worldContext.refs) === null || _b === void 0 ? void 0 : _b.rigidBodyRef) === null || _c === void 0 ? void 0 : _c.current))
|
|
11
|
+
worldContext.refs.rigidBodyRef.current.setTranslation(position, true);
|
|
9
12
|
};
|
|
10
13
|
return {
|
|
11
14
|
Teleport: Teleport,
|
|
@@ -1,22 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { activeStateType, clickerType, modeType } from "../../world/context/type";
|
|
1
|
+
import { gaesupWorldContextType } from "../../world/context/type";
|
|
3
2
|
import { calcType } from "../type";
|
|
4
|
-
export declare function orbitDirection({ activeState, control, mode, joystick, clicker, }:
|
|
5
|
-
|
|
6
|
-
mode: modeType;
|
|
7
|
-
joystick: joyStickInnerType;
|
|
8
|
-
clicker: clickerType;
|
|
9
|
-
control: {
|
|
10
|
-
[key: string]: boolean;
|
|
11
|
-
};
|
|
12
|
-
}): void;
|
|
13
|
-
export declare function normalDirection({ activeState, control, mode, joystick, clicker, }: {
|
|
14
|
-
activeState: activeStateType;
|
|
15
|
-
mode: modeType;
|
|
16
|
-
joystick: joyStickInnerType;
|
|
17
|
-
clicker: clickerType;
|
|
18
|
-
control: {
|
|
19
|
-
[key: string]: boolean;
|
|
20
|
-
};
|
|
21
|
-
}): void;
|
|
3
|
+
export declare function orbitDirection({ activeState, control, mode, joystick, clicker, clickerOption, }: Partial<gaesupWorldContextType>): void;
|
|
4
|
+
export declare function normalDirection({ activeState, control, mode, joystick, clicker, clickerOption, }: Partial<gaesupWorldContextType>): void;
|
|
22
5
|
export default function direction(prop: calcType): void;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { V3, calcAngleByVector } from "../../utils/vector";
|
|
2
2
|
export function orbitDirection(_a) {
|
|
3
|
-
var activeState = _a.activeState, control = _a.control, mode = _a.mode, joystick = _a.joystick, clicker = _a.clicker;
|
|
3
|
+
var activeState = _a.activeState, control = _a.control, mode = _a.mode, joystick = _a.joystick, clicker = _a.clicker, clickerOption = _a.clickerOption;
|
|
4
4
|
var forward = control.forward, backward = control.backward, leftward = control.leftward, rightward = control.rightward;
|
|
5
5
|
var dirX = Number(leftward) - Number(rightward);
|
|
6
6
|
var dirZ = Number(forward) - Number(backward);
|
|
@@ -26,7 +26,7 @@ export function orbitDirection(_a) {
|
|
|
26
26
|
activeState.dir = activeState.direction.normalize();
|
|
27
27
|
}
|
|
28
28
|
export function normalDirection(_a) {
|
|
29
|
-
var activeState = _a.activeState, control = _a.control, mode = _a.mode, joystick = _a.joystick, clicker = _a.clicker;
|
|
29
|
+
var activeState = _a.activeState, control = _a.control, mode = _a.mode, joystick = _a.joystick, clicker = _a.clicker, clickerOption = _a.clickerOption;
|
|
30
30
|
var forward = control.forward, backward = control.backward, leftward = control.leftward, rightward = control.rightward;
|
|
31
31
|
if (mode.controller === "joystick") {
|
|
32
32
|
if (joystick.joyStickOrigin.isCenter)
|
|
@@ -52,11 +52,11 @@ export function normalDirection(_a) {
|
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
export default function direction(prop) {
|
|
55
|
-
var
|
|
56
|
-
if (mode.control === "normal") {
|
|
57
|
-
normalDirection(
|
|
55
|
+
var worldContext = prop.worldContext;
|
|
56
|
+
if (worldContext.mode.control === "normal") {
|
|
57
|
+
normalDirection(worldContext);
|
|
58
58
|
}
|
|
59
|
-
else if (mode.control === "orbit") {
|
|
60
|
-
orbitDirection(
|
|
59
|
+
else if (worldContext.mode.control === "orbit") {
|
|
60
|
+
orbitDirection(worldContext);
|
|
61
61
|
}
|
|
62
62
|
}
|
|
@@ -1,17 +1,6 @@
|
|
|
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
1
|
import { vec3 } from "@react-three/rapier";
|
|
13
2
|
export default function impulse(prop) {
|
|
14
|
-
var rigidBodyRef = prop.rigidBodyRef, _a = prop.worldContext, states = _a.states, activeState = _a.activeState
|
|
3
|
+
var rigidBodyRef = prop.rigidBodyRef, _a = prop.worldContext, states = _a.states, activeState = _a.activeState;
|
|
15
4
|
var isMoving = states.isMoving, isRunning = states.isRunning;
|
|
16
5
|
var _b = prop.controllerContext.character, walkSpeed = _b.walkSpeed, runSpeed = _b.runSpeed, jumpSpeed = _b.jumpSpeed;
|
|
17
6
|
var isOnTheGround = states.isOnTheGround, isJumping = states.isJumping;
|
|
@@ -34,10 +23,4 @@ export default function impulse(prop) {
|
|
|
34
23
|
rigidBodyRef.current.applyImpulse(impulse, true);
|
|
35
24
|
activeState.position = vec3(rigidBodyRef.current.translation());
|
|
36
25
|
activeState.velocity = vec3(rigidBodyRef.current.linvel());
|
|
37
|
-
dispatch({
|
|
38
|
-
type: "update",
|
|
39
|
-
payload: {
|
|
40
|
-
activeState: __assign({}, activeState),
|
|
41
|
-
},
|
|
42
|
-
});
|
|
43
26
|
}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import direction from "./direction";
|
|
2
2
|
import impulse from "./impulse";
|
|
3
3
|
import innerCalc from "./innerCalc";
|
|
4
|
+
import queue from "./queue";
|
|
4
5
|
import stop from "./stop";
|
|
5
6
|
export default function characterCalculation(calcProp) {
|
|
6
7
|
direction(calcProp);
|
|
7
8
|
impulse(calcProp);
|
|
8
9
|
innerCalc(calcProp);
|
|
9
10
|
stop(calcProp);
|
|
11
|
+
queue(calcProp);
|
|
10
12
|
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { vec3 } from "@react-three/rapier";
|
|
2
|
+
import * as THREE from "three";
|
|
3
|
+
import { calcNorm } from "../../utils";
|
|
4
|
+
export default function queue(prop) {
|
|
5
|
+
var _a;
|
|
6
|
+
var rigidBodyRef = prop.rigidBodyRef, state = prop.state, _b = prop.worldContext, clicker = _b.clicker, mode = _b.mode, clickerOption = _b.clickerOption, block = _b.block;
|
|
7
|
+
var u = vec3((_a = rigidBodyRef.current) === null || _a === void 0 ? void 0 : _a.translation());
|
|
8
|
+
var norm = calcNorm(u, clicker.point, false);
|
|
9
|
+
if (clickerOption.autoStart) {
|
|
10
|
+
if (clickerOption.queue[0] instanceof THREE.Vector3) {
|
|
11
|
+
clicker.isOn = true;
|
|
12
|
+
norm = calcNorm(u, clickerOption.queue[0], false);
|
|
13
|
+
var v = vec3(clickerOption.queue[0]);
|
|
14
|
+
var newAngle = Math.atan2(v.z - u.z, v.x - u.x);
|
|
15
|
+
clicker.angle = newAngle;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
if (norm < 1 && mode.controller === "clicker") {
|
|
19
|
+
if (clickerOption.track && clickerOption.queue.length !== 0) {
|
|
20
|
+
var Q = clickerOption.queue.shift();
|
|
21
|
+
if (Q instanceof THREE.Vector3) {
|
|
22
|
+
clicker.point = Q;
|
|
23
|
+
var v = vec3(clicker.point);
|
|
24
|
+
var newAngle = Math.atan2(v.z - u.z, v.x - u.x);
|
|
25
|
+
clicker.angle = newAngle;
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
var action = Q.action, beforeCB = Q.beforeCB, afterCB_1 = Q.afterCB, time = Q.time;
|
|
29
|
+
if (action === "stop") {
|
|
30
|
+
state.clock.stop();
|
|
31
|
+
beforeCB(state);
|
|
32
|
+
console.log();
|
|
33
|
+
setTimeout(function () {
|
|
34
|
+
state.clock.start();
|
|
35
|
+
afterCB_1(state);
|
|
36
|
+
}, time);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
if (clickerOption.loop) {
|
|
40
|
+
clickerOption.queue.push(Q);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
clicker.isOn = false;
|
|
45
|
+
clicker.isRun = false;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -1,18 +1,8 @@
|
|
|
1
|
-
import { vec3 } from "@react-three/rapier";
|
|
2
|
-
import { calcNorm } from "../../utils";
|
|
3
1
|
export default function stop(prop) {
|
|
4
|
-
var _a;
|
|
5
|
-
var rigidBodyRef = prop.rigidBodyRef, _b = prop.worldContext, control = _b.control, clicker = _b.clicker, mode = _b.mode;
|
|
2
|
+
var _a = prop.worldContext, control = _a.control, clicker = _a.clicker, mode = _a.mode;
|
|
6
3
|
var keyS = control.keyS;
|
|
7
4
|
if (keyS && mode.controller === "clicker") {
|
|
8
5
|
clicker.isOn = false;
|
|
9
6
|
clicker.isRun = false;
|
|
10
7
|
}
|
|
11
|
-
// 목적지 도착
|
|
12
|
-
var u = vec3((_a = rigidBodyRef.current) === null || _a === void 0 ? void 0 : _a.translation());
|
|
13
|
-
var norm = calcNorm(u, clicker.point, false);
|
|
14
|
-
if (norm < 1 && mode.controller === "clicker") {
|
|
15
|
-
clicker.isOn = false;
|
|
16
|
-
clicker.isRun = false;
|
|
17
|
-
}
|
|
18
8
|
}
|
|
@@ -1,8 +1,23 @@
|
|
|
1
|
-
import { jsxs as _jsxs,
|
|
1
|
+
import { jsxs as _jsxs, jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { Line } from "@react-three/drei";
|
|
2
3
|
import { useContext } from "react";
|
|
4
|
+
import * as THREE from "three";
|
|
3
5
|
import { GaesupWorldContext } from "../../world/context";
|
|
4
6
|
export function Clicker(_a) {
|
|
5
7
|
var onMarker = _a.onMarker, runMarker = _a.runMarker;
|
|
6
8
|
var _b = useContext(GaesupWorldContext), clicker = _b.clicker, mode = _b.mode, clickerOption = _b.clickerOption;
|
|
7
|
-
|
|
9
|
+
var pointQ = [];
|
|
10
|
+
for (var i = 0; i < clickerOption.queue.length; i++) {
|
|
11
|
+
if (clickerOption.queue[i] instanceof THREE.Vector3) {
|
|
12
|
+
pointQ.push(clickerOption.queue[i]);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return (_jsxs(_Fragment, { children: [mode.controller === "clicker" && (_jsxs("group", { position: clicker.point, children: [clicker.isOn && onMarker, clicker.isOn && clickerOption.isRun && clicker.isRun && runMarker] })), clickerOption.line &&
|
|
16
|
+
pointQ.map(function (queueItem, key) {
|
|
17
|
+
if (queueItem instanceof THREE.Vector3) {
|
|
18
|
+
var current = key;
|
|
19
|
+
var before = key === 0 ? pointQ.length - 1 : key - 1;
|
|
20
|
+
return (_jsxs("group", { position: [0, 1, 0], children: [_jsx(Line, { worldUnits: true, points: [pointQ[before], pointQ[current]], color: "turquoise", transparent: true, opacity: 0.5, lineWidth: 0.4 }), _jsxs("mesh", { position: queueItem, children: [_jsx("sphereGeometry", { args: [0.6, 30, 0.6] }), _jsx("meshStandardMaterial", { color: "turquoise", transparent: true, opacity: 0.8 })] }, key)] }, key));
|
|
21
|
+
}
|
|
22
|
+
})] }));
|
|
8
23
|
}
|
|
@@ -48,7 +48,6 @@ export function Rideable(props) {
|
|
|
48
48
|
var _a;
|
|
49
49
|
var _b = useContext(GaesupWorldContext), states = _b.states, rideable = _b.rideable;
|
|
50
50
|
var _c = useRideable(), initRideable = _c.initRideable, ride = _c.ride, landing = _c.landing;
|
|
51
|
-
// const current = getRideable(props.objectkey);
|
|
52
51
|
var _rideable = useState({
|
|
53
52
|
position: props.position || V3(0, 0, 0),
|
|
54
53
|
rotation: props.rotation || euler(),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { RigidBodyProps } from "@react-three/rapier";
|
|
2
2
|
import * as THREE from "three";
|
|
3
3
|
import { controllerOptionsType } from "../../controller/type";
|
|
4
4
|
export type rideablePropType = {
|
|
@@ -19,7 +19,7 @@ export type rideablePropType = {
|
|
|
19
19
|
vehicleSize?: THREE.Vector3;
|
|
20
20
|
wheelSize?: THREE.Vector3;
|
|
21
21
|
airplaneSize?: THREE.Vector3;
|
|
22
|
-
rigidBodyProps?:
|
|
22
|
+
rigidBodyProps?: RigidBodyProps;
|
|
23
23
|
outerGroupProps?: THREE.Group;
|
|
24
24
|
innerGroupProps?: THREE.Group;
|
|
25
25
|
};
|
|
@@ -125,6 +125,11 @@ export var gaesupWorldDefault = {
|
|
|
125
125
|
clickerOption: {
|
|
126
126
|
isRun: true,
|
|
127
127
|
throttle: 100,
|
|
128
|
+
autoStart: false,
|
|
129
|
+
track: false,
|
|
130
|
+
loop: false,
|
|
131
|
+
queue: [],
|
|
132
|
+
line: false,
|
|
128
133
|
},
|
|
129
134
|
};
|
|
130
135
|
export var GaesupWorldContext = createContext(null);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { CSSProperties } from "react";
|
|
2
2
|
import { actionsType, refsType } from "../../controller/type";
|
|
3
|
+
import { RootState } from "@react-three/fiber";
|
|
3
4
|
import * as THREE from "three";
|
|
4
5
|
import { rideableType } from "../../hooks/useRideable/type";
|
|
5
6
|
import { joyStickInnerType } from "../../tools/joystick/type";
|
|
@@ -107,9 +108,23 @@ export type clickerType = {
|
|
|
107
108
|
isOn: boolean;
|
|
108
109
|
isRun: boolean;
|
|
109
110
|
};
|
|
111
|
+
export type queueActionType = "stop";
|
|
112
|
+
export type queueFunctionType = {
|
|
113
|
+
action: queueActionType;
|
|
114
|
+
beforeCB: (state: RootState) => void;
|
|
115
|
+
afterCB: (state: RootState) => void;
|
|
116
|
+
time: number;
|
|
117
|
+
};
|
|
118
|
+
export type queueItemtype = THREE.Vector3 | queueFunctionType;
|
|
119
|
+
export type queueType = queueItemtype[];
|
|
110
120
|
export type clickerOptionType = {
|
|
111
|
-
|
|
112
|
-
|
|
121
|
+
autoStart?: boolean;
|
|
122
|
+
isRun?: boolean;
|
|
123
|
+
throttle?: number;
|
|
124
|
+
track?: boolean;
|
|
125
|
+
loop?: boolean;
|
|
126
|
+
queue?: queueType;
|
|
127
|
+
line?: boolean;
|
|
113
128
|
};
|
|
114
129
|
export type wheelStateType = {
|
|
115
130
|
position: THREE.Vector3;
|
package/dist/index.js
CHANGED
|
@@ -12,7 +12,6 @@ export { JumpPortal } from "./gaesup/tools/jumpPortal";
|
|
|
12
12
|
export { KeyBoardToolTip } from "./gaesup/tools/keyBoardToolTip";
|
|
13
13
|
export { MiniMap } from "./gaesup/tools/miniMap";
|
|
14
14
|
export { Rideable } from "./gaesup/tools/rideable";
|
|
15
|
-
// export { ZoomButton } from "./gaesup/tools/zoomButton";
|
|
16
15
|
export { InnerHtml } from "./gaesup/utils/innerHtml";
|
|
17
16
|
export { Elr, Qt, V3, V30, V31 } from "./gaesup/utils/vector";
|
|
18
17
|
export { GaesupWorld } from "./gaesup/world";
|
package/package.json
CHANGED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
export default function detector(cameraProp) {
|
|
2
|
-
// const { cameraRay, intersectObjectMap } = cameraProp;
|
|
3
|
-
//
|
|
4
|
-
// const intersects = cameraRay.rayCast.intersectObjects(
|
|
5
|
-
// Object.values(intersectObjectMap)
|
|
6
|
-
// );
|
|
7
|
-
//
|
|
8
|
-
// const intersectId = {};
|
|
9
|
-
//
|
|
10
|
-
// intersects.map(({ object }) => {
|
|
11
|
-
// if (object instanceof THREE.Mesh) {
|
|
12
|
-
// intersectId[object.uuid] = true;
|
|
13
|
-
// }
|
|
14
|
-
// });
|
|
15
|
-
//
|
|
16
|
-
// Object.values(intersectObjectMap).map((mesh) => {
|
|
17
|
-
// if (mesh instanceof THREE.Mesh && mesh.material instanceof THREE.Material) {
|
|
18
|
-
// const material = mesh.material;
|
|
19
|
-
// if (intersectId[mesh.uuid]) {
|
|
20
|
-
// material.opacity = 0.2;
|
|
21
|
-
// material.transparent = true;
|
|
22
|
-
// } else {
|
|
23
|
-
// material.opacity = 1;
|
|
24
|
-
// material.transparent = false;
|
|
25
|
-
// }
|
|
26
|
-
// }
|
|
27
|
-
// });
|
|
28
|
-
}
|