gaesup-world 0.3.7 → 0.4.1
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/component/inner/character/index.d.ts +2 -1
- package/dist/gaesup/component/inner/character/index.js +2 -2
- package/dist/gaesup/component/inner/common/RigidbodyRef.d.ts +1 -0
- package/dist/gaesup/component/inner/common/RigidbodyRef.js +13 -3
- package/dist/gaesup/component/passive/character/index.d.ts +1 -0
- package/dist/gaesup/component/passive/character/index.js +1 -1
- package/dist/gaesup/physics/character/direction.js +2 -2
- package/dist/gaesup/physics/character/innerCalc.js +1 -3
- package/dist/gaesup/world/index.js +2 -3
- package/package.json +1 -2
- package/character.glb +0 -0
- package/grass_box.glb +0 -0
- package//341/204/206/341/205/256/341/204/214/341/205/246 3.png +0 -0
|
@@ -14,7 +14,7 @@ export type characterColliderType = {
|
|
|
14
14
|
radius: number;
|
|
15
15
|
diameter: number;
|
|
16
16
|
};
|
|
17
|
-
export declare function CharacterInnerRef({ children, refs, urls, position, euler, currentAnimation, }: {
|
|
17
|
+
export declare function CharacterInnerRef({ children, refs, urls, position, euler, currentAnimation, positionLerp, }: {
|
|
18
18
|
children: ReactNode;
|
|
19
19
|
refs: Partial<refsType>;
|
|
20
20
|
urls: urlsType;
|
|
@@ -22,4 +22,5 @@ export declare function CharacterInnerRef({ children, refs, urls, position, eule
|
|
|
22
22
|
euler?: THREE.Euler;
|
|
23
23
|
animationRef?: Ref<Object3D<Object3DEventMap>>;
|
|
24
24
|
currentAnimation?: string;
|
|
25
|
+
positionLerp?: number;
|
|
25
26
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -20,9 +20,9 @@ export var calcCharacterColliderProps = function (characterSize) {
|
|
|
20
20
|
};
|
|
21
21
|
};
|
|
22
22
|
export function CharacterInnerRef(_a) {
|
|
23
|
-
var children = _a.children, refs = _a.refs, urls = _a.urls, position = _a.position, euler = _a.euler, currentAnimation = _a.currentAnimation;
|
|
23
|
+
var children = _a.children, refs = _a.refs, urls = _a.urls, position = _a.position, euler = _a.euler, currentAnimation = _a.currentAnimation, positionLerp = _a.positionLerp;
|
|
24
24
|
var outerGroupRef = refs.outerGroupRef, rigidBodyRef = refs.rigidBodyRef, colliderRef = refs.colliderRef, innerGroupRef = refs.innerGroupRef;
|
|
25
25
|
var size = useGltfAndSize({ url: urls.characterUrl }).size;
|
|
26
26
|
var collider = calcCharacterColliderProps(size);
|
|
27
|
-
return (_jsx(_Fragment, { children: collider && (_jsx(OuterGroupRef, { ref: outerGroupRef, children: _jsxs(RigidBodyRef, { ref: rigidBodyRef, name: "character", position: position, rotation: euler, children: [_jsx(CapsuleCollider, { ref: colliderRef, args: [collider.height, collider.radius], position: [0, collider.height + collider.radius, 0] }), _jsx(InnerGroupRef, { type: "character", ref: innerGroupRef, url: urls.characterUrl, currentAnimation: currentAnimation, children: children })] }) })) }));
|
|
27
|
+
return (_jsx(_Fragment, { children: collider && (_jsx(OuterGroupRef, { ref: outerGroupRef, children: _jsxs(RigidBodyRef, { ref: rigidBodyRef, name: "character", position: position, positionLerp: positionLerp, rotation: euler, children: [_jsx(CapsuleCollider, { ref: colliderRef, args: [collider.height, collider.radius], position: [0, collider.height + collider.radius, 0] }), _jsx(InnerGroupRef, { type: "character", ref: innerGroupRef, url: urls.characterUrl, currentAnimation: currentAnimation, children: children })] }) })) }));
|
|
28
28
|
}
|
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { RigidBody, euler, } from "@react-three/rapier";
|
|
3
|
-
import { forwardRef } from "react";
|
|
3
|
+
import { forwardRef, useEffect, useState, } from "react";
|
|
4
4
|
export var RigidBodyRef = forwardRef(function (_a, ref) {
|
|
5
|
-
var children = _a.children, name = _a.name, position = _a.position, rotation = _a.rotation, userData = _a.userData, onCollisionEnter = _a.onCollisionEnter;
|
|
6
|
-
|
|
5
|
+
var children = _a.children, name = _a.name, position = _a.position, rotation = _a.rotation, userData = _a.userData, onCollisionEnter = _a.onCollisionEnter, positionLerp = _a.positionLerp;
|
|
6
|
+
var _b = useState(position), newPosition = _b[0], setNewPosition = _b[1];
|
|
7
|
+
useEffect(function () {
|
|
8
|
+
if (!positionLerp)
|
|
9
|
+
return;
|
|
10
|
+
if (position) {
|
|
11
|
+
setNewPosition(function (ordPosition) {
|
|
12
|
+
return ordPosition.lerp(position.clone(), positionLerp);
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
}, [position, positionLerp]);
|
|
16
|
+
return (_jsx(RigidBody, { colliders: false, ref: ref, name: name, position: positionLerp ? newPosition === null || newPosition === void 0 ? void 0 : newPosition.clone() : position, rotation: euler().set(0, (rotation === null || rotation === void 0 ? void 0 : rotation.clone().y) || 0, 0), userData: userData, onCollisionEnter: onCollisionEnter, children: children }));
|
|
7
17
|
});
|
|
@@ -7,5 +7,6 @@ export type passiveCharacterPropsType = {
|
|
|
7
7
|
currentAnimation: string;
|
|
8
8
|
gravityScale?: number;
|
|
9
9
|
children?: React.ReactNode;
|
|
10
|
+
positionLerp?: number;
|
|
10
11
|
};
|
|
11
12
|
export declare function PassiveCharacter(props: passiveCharacterPropsType): import("react/jsx-runtime").JSX.Element;
|
|
@@ -31,5 +31,5 @@ export function PassiveCharacter(props) {
|
|
|
31
31
|
innerGroupRef.current.quaternion.rotateTowards(quat().setFromEuler(euler), 10 * delta);
|
|
32
32
|
}
|
|
33
33
|
});
|
|
34
|
-
return (_jsx(CharacterInnerRef, { position: position, refs: refs, urls: props.urls, currentAnimation: props.currentAnimation, children: props.children }));
|
|
34
|
+
return (_jsx(CharacterInnerRef, { position: position, refs: refs, urls: props.urls, currentAnimation: props.currentAnimation, positionLerp: props.positionLerp, children: props.children }));
|
|
35
35
|
}
|
|
@@ -36,7 +36,7 @@ export function normalDirection(_a) {
|
|
|
36
36
|
}
|
|
37
37
|
else if (mode.controller === "clicker") {
|
|
38
38
|
activeState.euler.y = Math.PI / 2 - clicker.angle;
|
|
39
|
-
activeState.dir.set(-Math.sin(activeState.euler.y),
|
|
39
|
+
activeState.dir.set(-Math.sin(activeState.euler.y), 0, -Math.cos(activeState.euler.y));
|
|
40
40
|
}
|
|
41
41
|
else {
|
|
42
42
|
// 일반 컨트롤
|
|
@@ -52,7 +52,7 @@ export function normalDirection(_a) {
|
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
export default function direction(prop) {
|
|
55
|
-
var
|
|
55
|
+
var _a = prop.worldContext, joystick = _a.joystick, mode = _a.mode, activeState = _a.activeState, control = _a.control, clicker = _a.clicker;
|
|
56
56
|
if (mode.control === "normal") {
|
|
57
57
|
normalDirection({ activeState: activeState, control: control, mode: mode, joystick: joystick, clicker: clicker });
|
|
58
58
|
}
|
|
@@ -9,11 +9,9 @@ var __assign = (this && this.__assign) || function () {
|
|
|
9
9
|
};
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
11
|
};
|
|
12
|
-
import { quat
|
|
12
|
+
import { quat } from "@react-three/rapier";
|
|
13
13
|
export default function innerCalc(prop) {
|
|
14
14
|
var rigidBodyRef = prop.rigidBodyRef, innerGroupRef = prop.innerGroupRef, linearDamping = prop.controllerContext.character.linearDamping, _a = prop.worldContext, activeState = _a.activeState, states = _a.states, dispatch = prop.dispatch, delta = prop.delta;
|
|
15
|
-
activeState.position = vec3(rigidBodyRef.current.translation());
|
|
16
|
-
activeState.velocity = vec3(rigidBodyRef.current.linvel());
|
|
17
15
|
if (states.isJumping || rigidBodyRef.current.linvel().y < 0) {
|
|
18
16
|
rigidBodyRef.current.setLinearDamping(linearDamping);
|
|
19
17
|
}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as _jsx
|
|
3
|
-
import { Leva } from "leva";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
3
|
import { GaesupWorldContext, GaesupWorldDispatchContext } from "./context";
|
|
5
4
|
import initGaesupWorld from "./initalize";
|
|
6
5
|
import "./style.css";
|
|
7
6
|
export function GaesupWorld(props) {
|
|
8
7
|
var gaesupProps = initGaesupWorld(props).gaesupProps;
|
|
9
|
-
return (_jsx(GaesupWorldContext.Provider, { value: gaesupProps.value, children:
|
|
8
|
+
return (_jsx(GaesupWorldContext.Provider, { value: gaesupProps.value, children: _jsx(GaesupWorldDispatchContext.Provider, { value: gaesupProps.dispatch, children: props.children }) }));
|
|
10
9
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gaesup-world",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -25,7 +25,6 @@
|
|
|
25
25
|
"@types/three": "^0.161.2",
|
|
26
26
|
"gh-pages": "^6.1.1",
|
|
27
27
|
"leva": "0.9.35",
|
|
28
|
-
"lodash": "^4.17.21",
|
|
29
28
|
"node-fetch": "3.3.2",
|
|
30
29
|
"react": "^18.2.0",
|
|
31
30
|
"react-device-detect": "^2.2.3",
|
package/character.glb
DELETED
|
Binary file
|
package/grass_box.glb
DELETED
|
Binary file
|
|
Binary file
|