gaesup-world 0.2.5 → 0.2.6
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/animation/actions.d.ts +5 -0
- package/dist/gaesup/animation/actions.js +10 -0
- package/dist/gaesup/camera/control/normal.js +2 -1
- package/dist/gaesup/camera/index.js +38 -55
- package/dist/gaesup/component/passive/character/index.js +4 -13
- package/dist/gaesup/utils/debug.d.ts +1 -1
- package/dist/gaesup/world/context/index.js +3 -0
- package/dist/gaesup/world/context/type.d.ts +3 -0
- package/package.json +13 -13
|
@@ -42,3 +42,8 @@ export default function playActions({ type, animationResult, currentAnimation, }
|
|
|
42
42
|
animationRef: import("react").MutableRefObject<Object3D<Object3DEventMap>>;
|
|
43
43
|
currentAnimation: string;
|
|
44
44
|
};
|
|
45
|
+
export declare const setAnimation: ({ currentAnimation, actions, type, }: {
|
|
46
|
+
currentAnimation?: string;
|
|
47
|
+
actions?: actionsType;
|
|
48
|
+
type?: "character" | "vehicle" | "airplane";
|
|
49
|
+
}) => void;
|
|
@@ -101,3 +101,13 @@ export default function playActions(_a) {
|
|
|
101
101
|
currentAnimation: (_b = animationState === null || animationState === void 0 ? void 0 : animationState[type]) === null || _b === void 0 ? void 0 : _b.current,
|
|
102
102
|
};
|
|
103
103
|
}
|
|
104
|
+
export var setAnimation = function (_a) {
|
|
105
|
+
var currentAnimation = _a.currentAnimation, actions = _a.actions, type = _a.type;
|
|
106
|
+
useEffect(function () {
|
|
107
|
+
var _a;
|
|
108
|
+
var action = (_a = actions[currentAnimation]) === null || _a === void 0 ? void 0 : _a.reset().fadeIn(0.2).play();
|
|
109
|
+
return function () {
|
|
110
|
+
action === null || action === void 0 ? void 0 : action.fadeOut(0.2);
|
|
111
|
+
};
|
|
112
|
+
}, [currentAnimation, type]);
|
|
113
|
+
};
|
|
@@ -14,5 +14,6 @@ export default function normal(prop) {
|
|
|
14
14
|
.clone()
|
|
15
15
|
.add(V3(0, cameraOption.YDistance, cameraOption.ZDistance));
|
|
16
16
|
state.camera.position.lerp(cameraPosition, 1);
|
|
17
|
-
|
|
17
|
+
if (!cameraOption.target)
|
|
18
|
+
state.camera.lookAt(activeState.position.clone());
|
|
18
19
|
}
|
|
@@ -19,31 +19,32 @@ import { GaesupControllerContext } from "../controller/context";
|
|
|
19
19
|
import { GaesupWorldContext } from "../world/context";
|
|
20
20
|
import normal from "./control/normal";
|
|
21
21
|
import orbit from "./control/orbit";
|
|
22
|
-
import detector from "./detector";
|
|
23
22
|
export default function Camera(_a) {
|
|
24
23
|
var refs = _a.refs, prop = _a.prop, control = _a.control;
|
|
25
24
|
var worldContext = useContext(GaesupWorldContext);
|
|
26
25
|
var controllerContext = useContext(GaesupControllerContext);
|
|
27
|
-
var mode = worldContext.mode, cameraOption = worldContext.cameraOption;
|
|
26
|
+
var mode = worldContext.mode, cameraOption = worldContext.cameraOption, activeState = worldContext.activeState;
|
|
28
27
|
var rigidBodyRef = refs.rigidBodyRef, outerGroupRef = refs.outerGroupRef;
|
|
29
|
-
var
|
|
28
|
+
var camera = useThree().camera;
|
|
30
29
|
var cameraRef = useRef();
|
|
31
30
|
var intersectObjectMap = useMemo(function () { return ({}); }, []);
|
|
32
31
|
var cameraProp = __assign(__assign({}, prop), { control: control, controllerContext: controllerContext, worldContext: worldContext, intersectObjectMap: intersectObjectMap });
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
32
|
+
// const getMeshs = (object: THREE.Object3D) => {
|
|
33
|
+
// if (object.userData && object.userData.intangible) return;
|
|
34
|
+
// if (
|
|
35
|
+
// object instanceof THREE.Mesh &&
|
|
36
|
+
// object.geometry.type !== "InstancedBufferGeometry"
|
|
37
|
+
// ) {
|
|
38
|
+
// intersectObjectMap[object.uuid] = object;
|
|
39
|
+
// }
|
|
40
|
+
// object.children.forEach((child) => {
|
|
41
|
+
// getMeshs(child);
|
|
42
|
+
// });
|
|
43
|
+
// };
|
|
44
|
+
//
|
|
45
|
+
// useEffect(() => {
|
|
46
|
+
// scene.children.forEach((child) => getMeshs(child));
|
|
47
|
+
// }, []);
|
|
47
48
|
var position = useMemo(function () { return camera.position; }, []);
|
|
48
49
|
var dir = useMemo(function () { return vec3(); }, []);
|
|
49
50
|
cameraProp.cameraRay.rayCast = new THREE.Raycaster(cameraProp.cameraRay.origin, cameraProp.cameraRay.dir, 0, -cameraOption.maxDistance);
|
|
@@ -66,45 +67,27 @@ export default function Camera(_a) {
|
|
|
66
67
|
else if (mode.control === "normal") {
|
|
67
68
|
normal(cameraProp);
|
|
68
69
|
}
|
|
69
|
-
detector(cameraProp);
|
|
70
|
+
// detector(cameraProp);
|
|
70
71
|
}
|
|
71
72
|
});
|
|
72
|
-
//
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
//
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
// ),
|
|
92
|
-
// ]);
|
|
93
|
-
// } else if (mode.control === "normal") {
|
|
94
|
-
// await Promise.all([
|
|
95
|
-
// cameraRef.current.setPosition(0, position.y, position.z, true),
|
|
96
|
-
// camera.rotation.copy(worldContext.activeState.euler),
|
|
97
|
-
// cameraRef.current.setLookAt(
|
|
98
|
-
// 0,
|
|
99
|
-
// position.y,
|
|
100
|
-
// position.z,
|
|
101
|
-
// target.x,
|
|
102
|
-
// target.y,
|
|
103
|
-
// target.z,
|
|
104
|
-
// true
|
|
105
|
-
// ),
|
|
106
|
-
// ]);
|
|
107
|
-
// }
|
|
108
|
-
// };
|
|
73
|
+
// zoom
|
|
74
|
+
useEffect(function () {
|
|
75
|
+
if (cameraRef.current) {
|
|
76
|
+
cameraRef.current.zoomTo(worldContext.cameraOption.zoom, true);
|
|
77
|
+
}
|
|
78
|
+
}, [worldContext.cameraOption.zoom]);
|
|
79
|
+
// lookat
|
|
80
|
+
useEffect(function () {
|
|
81
|
+
if (cameraRef.current) {
|
|
82
|
+
var currentCamera = camera.position.clone();
|
|
83
|
+
if (cameraOption.focus) {
|
|
84
|
+
cameraRef.current.setLookAt(currentCamera.x, currentCamera.y, currentCamera.z, cameraOption.target.x, cameraOption.target.y, cameraOption.target.z, true);
|
|
85
|
+
// 포커스 품
|
|
86
|
+
}
|
|
87
|
+
else if (!cameraOption.focus) {
|
|
88
|
+
cameraRef.current.setLookAt(currentCamera.x, currentCamera.y, currentCamera.z, activeState.position.x, activeState.position.y, activeState.position.z, true);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}, [cameraOption.focus]);
|
|
109
92
|
return _jsx(CameraControls, { ref: cameraRef });
|
|
110
93
|
}
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useAnimations } from "@react-three/drei";
|
|
3
2
|
import { useFrame } from "@react-three/fiber";
|
|
4
3
|
import { quat } from "@react-three/rapier";
|
|
5
4
|
import { useEffect, useMemo, useRef } from "react";
|
|
6
|
-
import playActions from "../../../animation/actions";
|
|
7
|
-
import { useGltfAndSize } from "../../../hooks/useGaesupGltf";
|
|
8
5
|
import { CharacterInnerRef } from "../../inner/character";
|
|
9
6
|
export function PassiveCharacter(props) {
|
|
10
7
|
var rigidBodyRef = useRef(null);
|
|
@@ -21,13 +18,14 @@ export function PassiveCharacter(props) {
|
|
|
21
18
|
return {
|
|
22
19
|
position: props.position,
|
|
23
20
|
euler: props.euler,
|
|
24
|
-
currentAnimation: props.currentAnimation,
|
|
25
21
|
characterUrl: props.urls.characterUrl,
|
|
26
22
|
};
|
|
27
|
-
}, [props]), position = _a.position, euler = _a.euler
|
|
23
|
+
}, [props]), position = _a.position, euler = _a.euler;
|
|
28
24
|
useEffect(function () {
|
|
29
25
|
if (rigidBodyRef || rigidBodyRef.current) {
|
|
30
26
|
rigidBodyRef.current.setEnabledRotations(false, false, false, false);
|
|
27
|
+
// 중력 제거
|
|
28
|
+
rigidBodyRef.current.setGravityScale(0, true);
|
|
31
29
|
}
|
|
32
30
|
}, []);
|
|
33
31
|
useFrame(function (_, delta) {
|
|
@@ -35,12 +33,5 @@ export function PassiveCharacter(props) {
|
|
|
35
33
|
innerGroupRef.current.quaternion.rotateTowards(quat().setFromEuler(euler), 10 * delta);
|
|
36
34
|
}
|
|
37
35
|
});
|
|
38
|
-
|
|
39
|
-
var animationResult = useAnimations(gltf.animations);
|
|
40
|
-
var animationRef = playActions({
|
|
41
|
-
type: "character",
|
|
42
|
-
animationResult: animationResult,
|
|
43
|
-
currentAnimation: currentAnimation,
|
|
44
|
-
}).animationRef;
|
|
45
|
-
return (_jsx(CharacterInnerRef, { animationRef: animationRef, position: position, refs: refs, urls: props.urls, children: props.children }));
|
|
36
|
+
return (_jsx(CharacterInnerRef, { position: position, refs: refs, urls: props.urls, currentAnimation: props.currentAnimation, children: props.children }));
|
|
46
37
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gaesup-world",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -17,12 +17,12 @@
|
|
|
17
17
|
"deploy": "gh-pages -d dist"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@dimforge/rapier3d": "^0.
|
|
20
|
+
"@dimforge/rapier3d": "^0.12.0",
|
|
21
21
|
"@react-icons/all-files": "^4.1.0",
|
|
22
|
-
"@react-three/drei": "9.
|
|
23
|
-
"@react-three/fiber": "8.15.
|
|
22
|
+
"@react-three/drei": "9.97.0",
|
|
23
|
+
"@react-three/fiber": "8.15.16",
|
|
24
24
|
"@react-three/rapier": "^1.2.1",
|
|
25
|
-
"@types/three": "^0.
|
|
25
|
+
"@types/three": "^0.161.2",
|
|
26
26
|
"gh-pages": "^6.1.1",
|
|
27
27
|
"leva": "0.9.35",
|
|
28
28
|
"node-fetch": "3.3.2",
|
|
@@ -31,21 +31,21 @@
|
|
|
31
31
|
"react-dom": "^18.2.0",
|
|
32
32
|
"react-icons": "^5.0.1",
|
|
33
33
|
"react-use-refs": "^1.0.1",
|
|
34
|
-
"three": "^0.
|
|
34
|
+
"three": "^0.161.0"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@types/react": "^18.2.
|
|
37
|
+
"@types/react": "^18.2.52",
|
|
38
38
|
"@types/react-dom": "^18.2.18",
|
|
39
|
-
"@typescript-eslint/eslint-plugin": "^6.
|
|
40
|
-
"@typescript-eslint/parser": "^6.
|
|
41
|
-
"@vanilla-extract/css": "^1.14.
|
|
39
|
+
"@typescript-eslint/eslint-plugin": "^6.20.0",
|
|
40
|
+
"@typescript-eslint/parser": "^6.20.0",
|
|
41
|
+
"@vanilla-extract/css": "^1.14.1",
|
|
42
42
|
"@vanilla-extract/dynamic": "^2.1.0",
|
|
43
43
|
"@vanilla-extract/recipes": "^0.5.1",
|
|
44
44
|
"@vanilla-extract/sprinkles": "^1.6.1",
|
|
45
|
-
"@vanilla-extract/vite-plugin": "^
|
|
46
|
-
"@vitejs/plugin-react-swc": "^3.
|
|
45
|
+
"@vanilla-extract/vite-plugin": "^4.0.2",
|
|
46
|
+
"@vitejs/plugin-react-swc": "^3.6.0",
|
|
47
47
|
"copyfiles": "^2.4.1",
|
|
48
|
-
"css-loader": "^6.
|
|
48
|
+
"css-loader": "^6.10.0",
|
|
49
49
|
"eslint": "^8.56.0",
|
|
50
50
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
51
51
|
"eslint-plugin-react-refresh": "^0.4.5",
|