gaesup-world 0.8.4 → 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 +1 -5
- package/dist/gaesup/hooks/useClicker/index.d.ts +0 -1
- package/dist/gaesup/hooks/useClicker/index.js +1 -23
- package/dist/gaesup/hooks/useTeleport/index.js +7 -4
- 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 -22
- package/dist/gaesup/tools/clicker/index.js +13 -5
- package/dist/gaesup/tools/gamepad/style.css +0 -1
- package/dist/gaesup/tools/rideable/type.d.ts +2 -2
- package/dist/gaesup/world/context/type.d.ts +11 -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
|
};
|
|
@@ -21,7 +21,7 @@ export function GaeSupProps(_a) {
|
|
|
21
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);
|
|
@@ -46,9 +46,5 @@ export function GaeSupProps(_a) {
|
|
|
46
46
|
if (e.srcElement instanceof HTMLDivElement)
|
|
47
47
|
return;
|
|
48
48
|
moveClicker(e, false, type);
|
|
49
|
-
}, onDoubleClick: function (e) {
|
|
50
|
-
if (e.srcElement instanceof HTMLDivElement)
|
|
51
|
-
return;
|
|
52
|
-
moveDoubleClicker(e, true, type);
|
|
53
49
|
}, children: children }));
|
|
54
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,19 +1,8 @@
|
|
|
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
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")
|
|
@@ -33,18 +22,7 @@ export function useClicker() {
|
|
|
33
22
|
},
|
|
34
23
|
});
|
|
35
24
|
};
|
|
36
|
-
var moveDoubleClicker = function (e, isRun, type) {
|
|
37
|
-
if (!clicker.isOn || !clickerOption.isRun)
|
|
38
|
-
return;
|
|
39
|
-
dispatch({
|
|
40
|
-
type: "update",
|
|
41
|
-
payload: {
|
|
42
|
-
clicker: __assign(__assign({}, clicker), { isRun: isRun }),
|
|
43
|
-
},
|
|
44
|
-
});
|
|
45
|
-
};
|
|
46
25
|
return {
|
|
47
26
|
moveClicker: moveClicker,
|
|
48
|
-
moveDoubleClicker: moveDoubleClicker,
|
|
49
27
|
};
|
|
50
28
|
}
|
|
@@ -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,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,29 +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, clickerOption = _b.clickerOption, activeState = _b.activeState, dispatch = prop.dispatch;
|
|
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
|
-
if (clickerOption.track && clickerOption.queue.length !== 0) {
|
|
16
|
-
clicker.point = clickerOption.queue.shift();
|
|
17
|
-
var v = vec3(clicker.point);
|
|
18
|
-
var newAngle = Math.atan2(v.z - u.z, v.x - u.x);
|
|
19
|
-
clicker.angle = newAngle;
|
|
20
|
-
if (clickerOption.loop) {
|
|
21
|
-
clickerOption.queue.push(clicker.point);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
else {
|
|
25
|
-
clicker.isOn = false;
|
|
26
|
-
clicker.isRun = false;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
8
|
}
|
|
@@ -1,15 +1,23 @@
|
|
|
1
1
|
import { jsxs as _jsxs, jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { Line } from "@react-three/drei";
|
|
3
3
|
import { useContext } from "react";
|
|
4
|
+
import * as THREE from "three";
|
|
4
5
|
import { GaesupWorldContext } from "../../world/context";
|
|
5
6
|
export function Clicker(_a) {
|
|
6
7
|
var onMarker = _a.onMarker, runMarker = _a.runMarker;
|
|
7
8
|
var _b = useContext(GaesupWorldContext), clicker = _b.clicker, mode = _b.mode, clickerOption = _b.clickerOption;
|
|
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
|
+
}
|
|
8
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 &&
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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
|
+
}
|
|
14
22
|
})] }));
|
|
15
23
|
}
|
|
@@ -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
|
};
|
|
@@ -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,13 +108,22 @@ 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
121
|
autoStart?: boolean;
|
|
112
122
|
isRun?: boolean;
|
|
113
123
|
throttle?: number;
|
|
114
124
|
track?: boolean;
|
|
115
125
|
loop?: boolean;
|
|
116
|
-
queue?:
|
|
126
|
+
queue?: queueType;
|
|
117
127
|
line?: boolean;
|
|
118
128
|
};
|
|
119
129
|
export type wheelStateType = {
|
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
|
-
}
|