gaesup-world 0.0.662 → 0.0.663
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/package.json +1 -1
- package/src/gaesup/animation/actions.ts +0 -123
- package/src/gaesup/animation/index.ts +0 -1
- package/src/gaesup/camera/cameraCollisionDetecter.tsx +0 -53
- package/src/gaesup/camera/control/map.ts +0 -10
- package/src/gaesup/camera/control/normal.ts +0 -16
- package/src/gaesup/camera/control/orbit.ts +0 -31
- package/src/gaesup/camera/index.tsx +0 -102
- package/src/gaesup/camera/type.ts +0 -17
- package/src/gaesup/component/Airplane.tsx +0 -52
- package/src/gaesup/component/Character.tsx +0 -58
- package/src/gaesup/component/Vehicle.tsx +0 -43
- package/src/gaesup/component/gltf/AirplaneGltf.tsx +0 -31
- package/src/gaesup/component/gltf/CharacterGltf.tsx +0 -96
- package/src/gaesup/component/gltf/VehicleGltf.tsx +0 -31
- package/src/gaesup/component/gltf/WheelJoint.tsx +0 -39
- package/src/gaesup/component/gltf/index.ts +0 -4
- package/src/gaesup/component/gltf/type.ts +0 -7
- package/src/gaesup/component/index.ts +0 -5
- package/src/gaesup/component/ref/airplane.tsx +0 -97
- package/src/gaesup/component/ref/character.tsx +0 -137
- package/src/gaesup/component/ref/index.ts +0 -8
- package/src/gaesup/component/ref/vehicle.tsx +0 -122
- package/src/gaesup/component/setInit.ts +0 -14
- package/src/gaesup/controller/context/index.ts +0 -53
- package/src/gaesup/controller/context/reducer.ts +0 -18
- package/src/gaesup/controller/context/type.ts +0 -63
- package/src/gaesup/controller/index.tsx +0 -121
- package/src/gaesup/controller/type.ts +0 -149
- package/src/gaesup/gaesupProps/index.tsx +0 -66
- package/src/gaesup/index.ts +0 -8
- package/src/gaesup/initial/callback/index.ts +0 -73
- package/src/gaesup/initial/callback/type.ts +0 -47
- package/src/gaesup/initial/controller/index.ts +0 -157
- package/src/gaesup/initial/controller/initDebug.ts +0 -102
- package/src/gaesup/initial/gaesupWorld/collider/airplane.ts +0 -26
- package/src/gaesup/initial/gaesupWorld/collider/character.ts +0 -32
- package/src/gaesup/initial/gaesupWorld/collider/gltf.ts +0 -98
- package/src/gaesup/initial/gaesupWorld/collider/index.ts +0 -26
- package/src/gaesup/initial/gaesupWorld/collider/vehicle.ts +0 -43
- package/src/gaesup/initial/gaesupWorld/index.ts +0 -84
- package/src/gaesup/initial/gaesupWorld/type.ts +0 -38
- package/src/gaesup/initial/index.ts +0 -3
- package/src/gaesup/physics/airplane/currentSetting.ts +0 -20
- package/src/gaesup/physics/airplane/damping.ts +0 -6
- package/src/gaesup/physics/airplane/direction.ts +0 -79
- package/src/gaesup/physics/airplane/gravity.ts +0 -11
- package/src/gaesup/physics/airplane/impulse.ts +0 -28
- package/src/gaesup/physics/airplane/index.tsx +0 -16
- package/src/gaesup/physics/airplane/turn.ts +0 -11
- package/src/gaesup/physics/character/accelaration.ts +0 -14
- package/src/gaesup/physics/character/currentSetting.ts +0 -20
- package/src/gaesup/physics/character/damping.ts +0 -6
- package/src/gaesup/physics/character/direction.ts +0 -104
- package/src/gaesup/physics/character/impulse.ts +0 -24
- package/src/gaesup/physics/character/index.tsx +0 -20
- package/src/gaesup/physics/character/jump.ts +0 -21
- package/src/gaesup/physics/character/stabilizing.ts +0 -6
- package/src/gaesup/physics/character/turn.ts +0 -17
- package/src/gaesup/physics/check/ground.ts +0 -19
- package/src/gaesup/physics/check/index.ts +0 -12
- package/src/gaesup/physics/check/moving.ts +0 -20
- package/src/gaesup/physics/check/rotate.ts +0 -13
- package/src/gaesup/physics/check/slope.ts +0 -50
- package/src/gaesup/physics/index.ts +0 -50
- package/src/gaesup/physics/type.ts +0 -29
- package/src/gaesup/physics/vehicle/currentSetting.ts +0 -20
- package/src/gaesup/physics/vehicle/damping.ts +0 -12
- package/src/gaesup/physics/vehicle/direction.ts +0 -48
- package/src/gaesup/physics/vehicle/impulse.ts +0 -39
- package/src/gaesup/physics/vehicle/index.tsx +0 -14
- package/src/gaesup/physics/vehicle/turn.ts +0 -11
- package/src/gaesup/styles.css.ts +0 -26
- package/src/gaesup/tools/context.ts +0 -6
- package/src/gaesup/tools/gameboy/GameBoyButton.tsx +0 -47
- package/src/gaesup/tools/gameboy/default.ts +0 -3
- package/src/gaesup/tools/gameboy/index.tsx +0 -43
- package/src/gaesup/tools/gameboy/style.css.ts +0 -97
- package/src/gaesup/tools/gameboy/type.ts +0 -8
- package/src/gaesup/tools/gamepad/GamePadButton.tsx +0 -49
- package/src/gaesup/tools/gamepad/default.ts +0 -3
- package/src/gaesup/tools/gamepad/index.tsx +0 -59
- package/src/gaesup/tools/gamepad/style.css.ts +0 -71
- package/src/gaesup/tools/gamepad/type.ts +0 -9
- package/src/gaesup/tools/index.tsx +0 -78
- package/src/gaesup/tools/joystick/default.ts +0 -76
- package/src/gaesup/tools/joystick/index.tsx +0 -232
- package/src/gaesup/tools/joystick/style.css.ts +0 -51
- package/src/gaesup/tools/joystick/type.ts +0 -32
- package/src/gaesup/tools/jumpPoint/index.tsx +0 -28
- package/src/gaesup/tools/jumpPoint/style.css.ts +0 -34
- package/src/gaesup/tools/keyBoardToolTip/constant.ts +0 -128
- package/src/gaesup/tools/keyBoardToolTip/default.ts +0 -14
- package/src/gaesup/tools/keyBoardToolTip/index.tsx +0 -95
- package/src/gaesup/tools/keyBoardToolTip/style.css.ts +0 -49
- package/src/gaesup/tools/keyBoardToolTip/type.ts +0 -37
- package/src/gaesup/tools/minimap/default.ts +0 -9
- package/src/gaesup/tools/minimap/index.tsx +0 -82
- package/src/gaesup/tools/minimap/style.css.ts +0 -144
- package/src/gaesup/tools/minimap/type.ts +0 -27
- package/src/gaesup/tools/pushKey/index.ts +0 -26
- package/src/gaesup/tools/reducer.ts +0 -21
- package/src/gaesup/tools/style.css.ts +0 -34
- package/src/gaesup/tools/type.ts +0 -26
- package/src/gaesup/utils/constant.ts +0 -1
- package/src/gaesup/utils/index.ts +0 -3
- package/src/gaesup/utils/ray.ts +0 -23
- package/src/gaesup/utils/ref.ts +0 -17
- package/src/gaesup/utils/vector.ts +0 -40
- package/src/gaesup/world/context/index.ts +0 -133
- package/src/gaesup/world/context/reducer.ts +0 -21
- package/src/gaesup/world/context/type.ts +0 -139
- package/src/gaesup/world/index.tsx +0 -14
- package/src/gaesup/world/type.ts +0 -10
- package/src/index.ts +0 -7
- package/src/styles/constants/boxshadow.css.ts +0 -10
- package/src/styles/constants/constant.css.ts +0 -81
- package/src/styles/constants/direction.css.ts +0 -168
- package/src/styles/constants/flex.css.ts +0 -68
- package/src/styles/constants/gradient.css.ts +0 -10
- package/src/styles/constants/grid.css.ts +0 -37
- package/src/styles/constants/palette.css.ts +0 -91
- package/src/styles/constants/translate.css.ts +0 -129
- package/src/styles/global.css.ts +0 -91
- package/src/styles/recipe/base.css.ts +0 -31
- package/src/styles/recipe/button.css.ts +0 -109
- package/src/styles/recipe/index.css.ts +0 -134
- package/src/styles/recipe/input.css.ts +0 -33
- package/src/styles/sprinkles/color.css.ts +0 -62
- package/src/styles/sprinkles/direction.css.ts +0 -26
- package/src/styles/sprinkles/display.css.ts +0 -25
- package/src/styles/sprinkles/fontSize.css.ts +0 -25
- package/src/styles/sprinkles/grid.css.ts +0 -28
- package/src/styles/sprinkles/index.css.ts +0 -22
- package/src/styles/sprinkles/margin.css.ts +0 -30
- package/src/styles/sprinkles/padding.css.ts +0 -30
- package/src/styles/sprinkles/position.css.ts +0 -14
- package/src/styles/sprinkles/size.css.ts +0 -23
- package/src/styles/theme.css.ts +0 -98
- package/vite.config.ts +0 -9
package/package.json
CHANGED
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
import { useAnimations, useKeyboardControls } from "@react-three/drei";
|
|
2
|
-
import { useFrame } from "@react-three/fiber";
|
|
3
|
-
import { RefObject, useContext, useEffect } from "react";
|
|
4
|
-
import { animationTagType, groundRayType } from "../controller/type";
|
|
5
|
-
import {
|
|
6
|
-
GaesupWorldContext,
|
|
7
|
-
GaesupWorldDispatchContext,
|
|
8
|
-
} from "../world/context";
|
|
9
|
-
|
|
10
|
-
export type playActionsType = {
|
|
11
|
-
outerGroupRef: RefObject<THREE.Group>;
|
|
12
|
-
groundRay: groundRayType;
|
|
13
|
-
isRider?: boolean;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export default function playActions({
|
|
17
|
-
outerGroupRef,
|
|
18
|
-
groundRay,
|
|
19
|
-
isRider,
|
|
20
|
-
}: playActionsType) {
|
|
21
|
-
const { characterGltf, animations: characterAnimations } =
|
|
22
|
-
useContext(GaesupWorldContext);
|
|
23
|
-
const dispatch = useContext(GaesupWorldDispatchContext);
|
|
24
|
-
const { animations } = characterGltf;
|
|
25
|
-
const control = useKeyboardControls()[1]();
|
|
26
|
-
const { actions } = useAnimations(animations, outerGroupRef);
|
|
27
|
-
|
|
28
|
-
useEffect(() => {
|
|
29
|
-
characterAnimations.keyControl = control;
|
|
30
|
-
dispatch({
|
|
31
|
-
type: "update",
|
|
32
|
-
payload: {
|
|
33
|
-
animations: {
|
|
34
|
-
...characterAnimations,
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
|
-
});
|
|
38
|
-
}, [control]);
|
|
39
|
-
|
|
40
|
-
const playAnimation = (tag: keyof animationTagType) => {
|
|
41
|
-
characterAnimations.current = tag;
|
|
42
|
-
dispatch({
|
|
43
|
-
type: "update",
|
|
44
|
-
payload: {
|
|
45
|
-
animations: {
|
|
46
|
-
...characterAnimations,
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
|
-
});
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
const setAnimationName = (actions: {
|
|
53
|
-
[x: string]: THREE.AnimationAction | null;
|
|
54
|
-
}) => {
|
|
55
|
-
characterAnimations.animationNames = Object.assign(
|
|
56
|
-
characterAnimations.animationNames,
|
|
57
|
-
Object.keys(actions).reduce((acc, cur) => {
|
|
58
|
-
return {
|
|
59
|
-
...acc,
|
|
60
|
-
[cur]: cur,
|
|
61
|
-
};
|
|
62
|
-
}, {})
|
|
63
|
-
);
|
|
64
|
-
dispatch({
|
|
65
|
-
type: "update",
|
|
66
|
-
payload: {
|
|
67
|
-
animations: {
|
|
68
|
-
...characterAnimations,
|
|
69
|
-
},
|
|
70
|
-
},
|
|
71
|
-
});
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
const resetAni = () => playAnimation("idle");
|
|
75
|
-
const playIdle = () => playAnimation("idle");
|
|
76
|
-
const playWalk = () => playAnimation("walk");
|
|
77
|
-
const playRun = () => playAnimation("run");
|
|
78
|
-
const playJump = () => playAnimation("jump");
|
|
79
|
-
const playFall = () => playAnimation("fall");
|
|
80
|
-
const playRide = () => playAnimation("ride");
|
|
81
|
-
|
|
82
|
-
useEffect(() => {
|
|
83
|
-
return () => {
|
|
84
|
-
resetAni();
|
|
85
|
-
};
|
|
86
|
-
}, []);
|
|
87
|
-
|
|
88
|
-
useEffect(() => {
|
|
89
|
-
// Play animation
|
|
90
|
-
const action = actions[characterAnimations.current]
|
|
91
|
-
?.reset()
|
|
92
|
-
.fadeIn(0.2)
|
|
93
|
-
.play();
|
|
94
|
-
setAnimationName(actions);
|
|
95
|
-
return () => {
|
|
96
|
-
action?.fadeOut(0.2);
|
|
97
|
-
};
|
|
98
|
-
}, [characterAnimations.current]);
|
|
99
|
-
|
|
100
|
-
const { states, activeState } = useContext(GaesupWorldContext);
|
|
101
|
-
const { isNotMoving, isMoving, isJumping, isRunning, isAnimationOuter } =
|
|
102
|
-
states;
|
|
103
|
-
useFrame(() => {
|
|
104
|
-
if (isRider) {
|
|
105
|
-
playRide();
|
|
106
|
-
} else {
|
|
107
|
-
if (!isAnimationOuter) {
|
|
108
|
-
if (isJumping) {
|
|
109
|
-
playJump();
|
|
110
|
-
} else if (isNotMoving) {
|
|
111
|
-
playIdle();
|
|
112
|
-
} else if (isRunning) {
|
|
113
|
-
playRun();
|
|
114
|
-
} else if (isMoving) {
|
|
115
|
-
playWalk();
|
|
116
|
-
}
|
|
117
|
-
if (groundRay.hit === null && activeState.velocity.y < 0) {
|
|
118
|
-
playFall();
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
});
|
|
123
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * as playActions from "./actions";
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { propType } from "../controller/type";
|
|
2
|
-
|
|
3
|
-
export default function cameraCollisionDetector(prop: propType) {
|
|
4
|
-
// const { cameraRay, constant, options } = prop;
|
|
5
|
-
// const { camera } = useThree();
|
|
6
|
-
const checkCollision = (delta: number) => {
|
|
7
|
-
// cameraRay.origin.copy(cameraRay.pivot.position);
|
|
8
|
-
// camera.getWorldPosition(cameraRay.position);
|
|
9
|
-
// cameraRay.dir.subVectors(cameraRay.position, cameraRay.pivot.position);
|
|
10
|
-
// cameraRay.intersects = cameraRay.rayCast!.intersectObjects(
|
|
11
|
-
// Object.values(cameraRay.intersectObjectMap)
|
|
12
|
-
// );
|
|
13
|
-
// if (
|
|
14
|
-
// cameraRay.intersects.length &&
|
|
15
|
-
// cameraRay.intersects[0].distance <= -constant.cameraInitDistance
|
|
16
|
-
// ) {
|
|
17
|
-
// if (options.cameraCollisionType === "transparent") {
|
|
18
|
-
// cameraRay.intersetesAndTransParented = [...cameraRay.intersects];
|
|
19
|
-
// cameraRay.intersetesAndTransParented.map((intersect) => {
|
|
20
|
-
// const mesh = intersect.object as THREE.Mesh;
|
|
21
|
-
// const material = mesh.material as THREE.MeshStandardMaterial;
|
|
22
|
-
// material.opacity = 0.2;
|
|
23
|
-
// material.transparent = true;
|
|
24
|
-
// });
|
|
25
|
-
// } else if (options.cameraCollisionType === "closeUp") {
|
|
26
|
-
// constant.cameraMinDistance =
|
|
27
|
-
// -cameraRay.intersects[0].distance * constant.cameraCollisionOff < -0.7
|
|
28
|
-
// ? -cameraRay.intersects[0].distance * constant.cameraCollisionOff
|
|
29
|
-
// : -0.7;
|
|
30
|
-
// }
|
|
31
|
-
// } else {
|
|
32
|
-
// if (options.cameraCollisionType === "transparent") {
|
|
33
|
-
// cameraRay.intersetesAndTransParented.map((intersect) => {
|
|
34
|
-
// const mesh = intersect.object as THREE.Mesh;
|
|
35
|
-
// const material = mesh.material as THREE.MeshStandardMaterial;
|
|
36
|
-
// material.opacity = 1;
|
|
37
|
-
// material.transparent = false;
|
|
38
|
-
// });
|
|
39
|
-
// cameraRay.intersetesAndTransParented = [];
|
|
40
|
-
// }
|
|
41
|
-
// constant.cameraMinDistance = constant.cameraInitDistance;
|
|
42
|
-
// }
|
|
43
|
-
// cameraRay.lerpingPoint.set(
|
|
44
|
-
// cameraRay.followCamera.position.x,
|
|
45
|
-
// constant.cameraMinDistance * Math.sin(-cameraRay.followCamera.rotation.x),
|
|
46
|
-
// constant.cameraMinDistance * Math.cos(-cameraRay.followCamera.rotation.x)
|
|
47
|
-
// );
|
|
48
|
-
//
|
|
49
|
-
// cameraRay.followCamera.position.lerp(cameraRay.lerpingPoint, delta * 4);
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
return { checkCollision };
|
|
53
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { cameraPropType } from "../../physics/type";
|
|
2
|
-
|
|
3
|
-
export default function mapControl(prop: cameraPropType) {
|
|
4
|
-
const {
|
|
5
|
-
state,
|
|
6
|
-
worldContext: { activeState },
|
|
7
|
-
} = prop;
|
|
8
|
-
const position = activeState.position.clone();
|
|
9
|
-
state.camera.position.set(-10, 10, -10).add(position);
|
|
10
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { cameraPropType } from "../../physics/type";
|
|
2
|
-
import { V3 } from "../../utils/vector";
|
|
3
|
-
|
|
4
|
-
export default function normal(prop: cameraPropType) {
|
|
5
|
-
const {
|
|
6
|
-
state,
|
|
7
|
-
controllerContext: { perspectiveCamera },
|
|
8
|
-
worldContext: { activeState },
|
|
9
|
-
} = prop;
|
|
10
|
-
const cameraPosition = activeState.position
|
|
11
|
-
.clone()
|
|
12
|
-
.add(V3(perspectiveCamera.XZDistance, perspectiveCamera.YDistance, 0));
|
|
13
|
-
|
|
14
|
-
state.camera.position.lerp(cameraPosition, 1);
|
|
15
|
-
state.camera.lookAt(activeState.position.clone());
|
|
16
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { quat } from "@react-three/rapier";
|
|
2
|
-
import { cameraPropType } from "../../physics/type";
|
|
3
|
-
import { V3 } from "../../utils/vector";
|
|
4
|
-
|
|
5
|
-
export default function orbit(prop: cameraPropType) {
|
|
6
|
-
const {
|
|
7
|
-
state,
|
|
8
|
-
controllerContext: { perspectiveCamera },
|
|
9
|
-
worldContext: { activeState },
|
|
10
|
-
} = prop;
|
|
11
|
-
const cameraPosition = activeState.position.clone().add(
|
|
12
|
-
V3(Math.sin(activeState.euler.y), 0, Math.cos(activeState.euler.y))
|
|
13
|
-
.normalize()
|
|
14
|
-
.clone()
|
|
15
|
-
.multiplyScalar(perspectiveCamera.XZDistance)
|
|
16
|
-
.multiplyScalar(perspectiveCamera.isFront ? -1 : 1)
|
|
17
|
-
.add(V3(0, perspectiveCamera.YDistance, 0))
|
|
18
|
-
);
|
|
19
|
-
|
|
20
|
-
state.camera.position.lerp(cameraPosition, 0.5);
|
|
21
|
-
state.camera.quaternion.copy(
|
|
22
|
-
activeState.quat
|
|
23
|
-
.clone()
|
|
24
|
-
.multiply(
|
|
25
|
-
perspectiveCamera.isFront
|
|
26
|
-
? quat().setFromAxisAngle(V3(0, 1, 0), Math.PI)
|
|
27
|
-
: quat()
|
|
28
|
-
)
|
|
29
|
-
);
|
|
30
|
-
state.camera.lookAt(activeState.position);
|
|
31
|
-
}
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
MapControls,
|
|
3
|
-
OrbitControls,
|
|
4
|
-
OrthographicCamera,
|
|
5
|
-
PerspectiveCamera,
|
|
6
|
-
} from "@react-three/drei";
|
|
7
|
-
import { useFrame, useThree } from "@react-three/fiber";
|
|
8
|
-
import { useContext } from "react";
|
|
9
|
-
import * as THREE from "three";
|
|
10
|
-
import { GaesupControllerContext } from "../controller/context";
|
|
11
|
-
import { propType, refsType } from "../controller/type";
|
|
12
|
-
import { cameraPropType } from "../physics/type";
|
|
13
|
-
import { GaesupWorldContext } from "../world/context";
|
|
14
|
-
import cameraCollisionDetector from "./cameraCollisionDetecter";
|
|
15
|
-
import mapControl from "./control/map";
|
|
16
|
-
import normal from "./control/normal";
|
|
17
|
-
import orbit from "./control/orbit";
|
|
18
|
-
|
|
19
|
-
export default function Camera({
|
|
20
|
-
refs,
|
|
21
|
-
prop,
|
|
22
|
-
control,
|
|
23
|
-
}: {
|
|
24
|
-
refs: refsType;
|
|
25
|
-
prop: propType;
|
|
26
|
-
control: {
|
|
27
|
-
[key: string]: boolean;
|
|
28
|
-
};
|
|
29
|
-
}) {
|
|
30
|
-
const worldContext = useContext(GaesupWorldContext);
|
|
31
|
-
const controllerContext = useContext(GaesupControllerContext);
|
|
32
|
-
const { cameraMode, perspectiveCamera, orthographicCamera } =
|
|
33
|
-
controllerContext;
|
|
34
|
-
const { rigidBodyRef, outerGroupRef } = refs;
|
|
35
|
-
const { cameraRay } = prop;
|
|
36
|
-
const { checkCollision } = cameraCollisionDetector(prop);
|
|
37
|
-
const { scene } = useThree();
|
|
38
|
-
const { activeState } = worldContext;
|
|
39
|
-
|
|
40
|
-
const intersectObjectMap: { [uuid: string]: THREE.Object3D } = {};
|
|
41
|
-
const cameraProp: cameraPropType = {
|
|
42
|
-
...prop,
|
|
43
|
-
checkCollision,
|
|
44
|
-
control,
|
|
45
|
-
controllerContext,
|
|
46
|
-
worldContext,
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
const getMeshs = (object: THREE.Object3D) => {
|
|
50
|
-
if (object.userData && object.userData.intangible) return;
|
|
51
|
-
if (
|
|
52
|
-
object instanceof THREE.Mesh &&
|
|
53
|
-
object.geometry.type !== "InstancedBufferGeometry"
|
|
54
|
-
) {
|
|
55
|
-
intersectObjectMap[object.uuid] = object;
|
|
56
|
-
}
|
|
57
|
-
object.children.forEach((child) => {
|
|
58
|
-
getMeshs(child);
|
|
59
|
-
});
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
useFrame((state, delta) => {
|
|
63
|
-
if (
|
|
64
|
-
!rigidBodyRef ||
|
|
65
|
-
!rigidBodyRef.current ||
|
|
66
|
-
!outerGroupRef ||
|
|
67
|
-
!outerGroupRef.current
|
|
68
|
-
)
|
|
69
|
-
return null;
|
|
70
|
-
cameraProp.state = state;
|
|
71
|
-
cameraProp.delta = delta;
|
|
72
|
-
|
|
73
|
-
if (cameraMode.cameraType === "perspective") {
|
|
74
|
-
scene.children.forEach((child) => getMeshs(child));
|
|
75
|
-
cameraRay.intersectObjectMap = intersectObjectMap;
|
|
76
|
-
if (cameraMode.controlType === "orbit") {
|
|
77
|
-
orbit(cameraProp);
|
|
78
|
-
} else if (cameraMode.controlType === "normal") {
|
|
79
|
-
normal(cameraProp);
|
|
80
|
-
}
|
|
81
|
-
} else if (cameraMode.cameraType === "orthographic") {
|
|
82
|
-
mapControl(cameraProp);
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
return (
|
|
87
|
-
<>
|
|
88
|
-
{cameraMode.cameraType === "perspective" && (
|
|
89
|
-
<>
|
|
90
|
-
<OrbitControls target={activeState.position} />
|
|
91
|
-
<PerspectiveCamera makeDefault {...perspectiveCamera} />
|
|
92
|
-
</>
|
|
93
|
-
)}
|
|
94
|
-
{cameraMode.cameraType === "orthographic" && (
|
|
95
|
-
<>
|
|
96
|
-
<MapControls target={activeState.position} />
|
|
97
|
-
<OrthographicCamera makeDefault {...orthographicCamera} />
|
|
98
|
-
</>
|
|
99
|
-
)}
|
|
100
|
-
</>
|
|
101
|
-
);
|
|
102
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export type cameraRayType = {
|
|
2
|
-
origin: THREE.Vector3;
|
|
3
|
-
hit: THREE.Raycaster;
|
|
4
|
-
rayCast: THREE.Raycaster | null;
|
|
5
|
-
lerpingPoint: THREE.Vector3;
|
|
6
|
-
length: number;
|
|
7
|
-
dir: THREE.Vector3;
|
|
8
|
-
position: THREE.Vector3;
|
|
9
|
-
followCamera: THREE.Object3D;
|
|
10
|
-
pivot: THREE.Object3D;
|
|
11
|
-
intersetesAndTransParented: THREE.Intersection<
|
|
12
|
-
THREE.Object3D<THREE.Object3DEventMap>
|
|
13
|
-
>[];
|
|
14
|
-
intersects: THREE.Intersection<THREE.Object3D<THREE.Object3DEventMap>>[];
|
|
15
|
-
intersectObjects: THREE.Object3D[];
|
|
16
|
-
intersectObjectMap: { [uuid: string]: THREE.Object3D };
|
|
17
|
-
};
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import { propType, refsType } from "../controller/type";
|
|
4
|
-
import calculation from "../physics";
|
|
5
|
-
import { AirplaneInnerGroupRef } from "./gltf/AirplaneGltf";
|
|
6
|
-
import { CharacterInnerGroupRef } from "./gltf/CharacterGltf";
|
|
7
|
-
import {
|
|
8
|
-
AirplaneCollider,
|
|
9
|
-
AirplaneGroup,
|
|
10
|
-
AirplaneRigidBody,
|
|
11
|
-
} from "./ref/airplane";
|
|
12
|
-
import setInit from "./setInit";
|
|
13
|
-
|
|
14
|
-
export function Airplane({
|
|
15
|
-
controllerProps,
|
|
16
|
-
refs,
|
|
17
|
-
}: {
|
|
18
|
-
controllerProps: propType;
|
|
19
|
-
refs: refsType;
|
|
20
|
-
}) {
|
|
21
|
-
const {
|
|
22
|
-
rigidBodyRef,
|
|
23
|
-
outerGroupRef,
|
|
24
|
-
capsuleColliderRef,
|
|
25
|
-
innerGroupRef,
|
|
26
|
-
characterInnerRef,
|
|
27
|
-
} = refs;
|
|
28
|
-
calculation(controllerProps);
|
|
29
|
-
setInit(rigidBodyRef);
|
|
30
|
-
|
|
31
|
-
return (
|
|
32
|
-
<>
|
|
33
|
-
<AirplaneGroup ref={outerGroupRef} controllerProps={controllerProps}>
|
|
34
|
-
<AirplaneRigidBody ref={rigidBodyRef} controllerProps={controllerProps}>
|
|
35
|
-
<AirplaneCollider prop={controllerProps} ref={capsuleColliderRef} />
|
|
36
|
-
{controllerProps.isRider && (
|
|
37
|
-
<CharacterInnerGroupRef
|
|
38
|
-
prop={controllerProps}
|
|
39
|
-
groupProps={controllerProps.groupProps}
|
|
40
|
-
groundRay={controllerProps.groundRay}
|
|
41
|
-
refs={refs}
|
|
42
|
-
callbacks={controllerProps.callbacks}
|
|
43
|
-
isRider={controllerProps.isRider}
|
|
44
|
-
ref={characterInnerRef}
|
|
45
|
-
/>
|
|
46
|
-
)}
|
|
47
|
-
<AirplaneInnerGroupRef ref={innerGroupRef} />
|
|
48
|
-
</AirplaneRigidBody>
|
|
49
|
-
</AirplaneGroup>
|
|
50
|
-
</>
|
|
51
|
-
);
|
|
52
|
-
}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import calculation from "../physics";
|
|
4
|
-
|
|
5
|
-
import { propType, refsType } from "../controller/type";
|
|
6
|
-
import { CharacterInnerGroupRef, InnerGroupRef } from "./gltf/CharacterGltf";
|
|
7
|
-
import {
|
|
8
|
-
CharacterCapsuleCollider,
|
|
9
|
-
CharacterGroup,
|
|
10
|
-
CharacterRigidBody,
|
|
11
|
-
CharacterSlopeRay,
|
|
12
|
-
} from "./ref/character";
|
|
13
|
-
import setInit from "./setInit";
|
|
14
|
-
|
|
15
|
-
export function Character({
|
|
16
|
-
controllerProps,
|
|
17
|
-
refs,
|
|
18
|
-
}: {
|
|
19
|
-
controllerProps: propType;
|
|
20
|
-
refs: refsType;
|
|
21
|
-
}) {
|
|
22
|
-
const {
|
|
23
|
-
capsuleColliderRef,
|
|
24
|
-
rigidBodyRef,
|
|
25
|
-
outerGroupRef,
|
|
26
|
-
slopeRayOriginRef,
|
|
27
|
-
characterInnerRef,
|
|
28
|
-
innerGroupRef,
|
|
29
|
-
} = refs;
|
|
30
|
-
calculation(controllerProps);
|
|
31
|
-
setInit(rigidBodyRef);
|
|
32
|
-
return (
|
|
33
|
-
<CharacterRigidBody ref={rigidBodyRef} controllerProps={controllerProps}>
|
|
34
|
-
<CharacterCapsuleCollider
|
|
35
|
-
prop={controllerProps}
|
|
36
|
-
ref={capsuleColliderRef}
|
|
37
|
-
/>
|
|
38
|
-
<CharacterGroup ref={outerGroupRef} controllerProps={controllerProps}>
|
|
39
|
-
<CharacterSlopeRay
|
|
40
|
-
slopeRay={controllerProps.slopeRay}
|
|
41
|
-
groundRay={controllerProps.groundRay}
|
|
42
|
-
ref={slopeRayOriginRef}
|
|
43
|
-
/>
|
|
44
|
-
{controllerProps.children}
|
|
45
|
-
<InnerGroupRef ref={innerGroupRef} />
|
|
46
|
-
<CharacterInnerGroupRef
|
|
47
|
-
prop={controllerProps}
|
|
48
|
-
groupProps={controllerProps.groupProps}
|
|
49
|
-
groundRay={controllerProps.groundRay}
|
|
50
|
-
refs={refs}
|
|
51
|
-
callbacks={controllerProps.callbacks}
|
|
52
|
-
ref={characterInnerRef}
|
|
53
|
-
isRider={false}
|
|
54
|
-
/>
|
|
55
|
-
</CharacterGroup>
|
|
56
|
-
</CharacterRigidBody>
|
|
57
|
-
);
|
|
58
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import { propType, refsType } from "../controller/type";
|
|
4
|
-
import calculation from "../physics";
|
|
5
|
-
import { CharacterInnerGroupRef } from "./gltf/CharacterGltf";
|
|
6
|
-
import { VehicleInnerGroupRef } from "./gltf/VehicleGltf";
|
|
7
|
-
import { Wheels } from "./gltf/WheelJoint";
|
|
8
|
-
import { VehicleCollider, VehicleGroup, VehicleRigidBody } from "./ref/vehicle";
|
|
9
|
-
import setInit from "./setInit";
|
|
10
|
-
|
|
11
|
-
export function Vehicle({
|
|
12
|
-
controllerProps,
|
|
13
|
-
refs,
|
|
14
|
-
}: {
|
|
15
|
-
controllerProps: propType;
|
|
16
|
-
refs: refsType;
|
|
17
|
-
}) {
|
|
18
|
-
const { rigidBodyRef, outerGroupRef, characterInnerRef, innerGroupRef } =
|
|
19
|
-
refs;
|
|
20
|
-
calculation(controllerProps);
|
|
21
|
-
setInit(rigidBodyRef);
|
|
22
|
-
|
|
23
|
-
return (
|
|
24
|
-
<VehicleGroup ref={outerGroupRef} controllerProps={controllerProps}>
|
|
25
|
-
<VehicleRigidBody ref={rigidBodyRef} controllerProps={controllerProps}>
|
|
26
|
-
<VehicleCollider />
|
|
27
|
-
{controllerProps.isRider && (
|
|
28
|
-
<CharacterInnerGroupRef
|
|
29
|
-
prop={controllerProps}
|
|
30
|
-
groupProps={controllerProps.groupProps}
|
|
31
|
-
groundRay={controllerProps.groundRay}
|
|
32
|
-
refs={refs}
|
|
33
|
-
callbacks={controllerProps.callbacks}
|
|
34
|
-
ref={characterInnerRef}
|
|
35
|
-
isRider={true}
|
|
36
|
-
/>
|
|
37
|
-
)}
|
|
38
|
-
<VehicleInnerGroupRef ref={innerGroupRef} />
|
|
39
|
-
</VehicleRigidBody>
|
|
40
|
-
<Wheels prop={controllerProps} />
|
|
41
|
-
</VehicleGroup>
|
|
42
|
-
);
|
|
43
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { Ref, forwardRef, useContext } from "react";
|
|
2
|
-
import { GaesupWorldContext } from "../../world/context";
|
|
3
|
-
|
|
4
|
-
export const AirplaneInnerGroupRef = forwardRef((_, ref: Ref<THREE.Group>) => {
|
|
5
|
-
const { airplaneGltf: gltf } = useContext(GaesupWorldContext);
|
|
6
|
-
const { materials, nodes } = gltf;
|
|
7
|
-
return (
|
|
8
|
-
<>
|
|
9
|
-
{nodes && materials && (
|
|
10
|
-
<group receiveShadow castShadow ref={ref}>
|
|
11
|
-
{Object.keys(nodes).map((name: string, key: number) => {
|
|
12
|
-
if (
|
|
13
|
-
nodes[name].type === "Mesh" ||
|
|
14
|
-
nodes[name].type === "SkinnedMesh"
|
|
15
|
-
) {
|
|
16
|
-
return (
|
|
17
|
-
<mesh
|
|
18
|
-
castShadow
|
|
19
|
-
receiveShadow
|
|
20
|
-
material={materials[name]}
|
|
21
|
-
geometry={nodes[name].geometry}
|
|
22
|
-
key={key}
|
|
23
|
-
/>
|
|
24
|
-
);
|
|
25
|
-
}
|
|
26
|
-
})}
|
|
27
|
-
</group>
|
|
28
|
-
)}
|
|
29
|
-
</>
|
|
30
|
-
);
|
|
31
|
-
});
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import { GroupProps } from "@react-three/fiber";
|
|
2
|
-
import { Ref, forwardRef, useContext } from "react";
|
|
3
|
-
import playActions from "../../animation/actions";
|
|
4
|
-
import { groundRayType, propType, refsType } from "../../controller/type";
|
|
5
|
-
import initCallback from "../../initial/callback";
|
|
6
|
-
import { callbackType } from "../../initial/callback/type";
|
|
7
|
-
import { GaesupWorldContext } from "../../world/context";
|
|
8
|
-
|
|
9
|
-
export type characterGltfType = {
|
|
10
|
-
prop: propType;
|
|
11
|
-
groupProps?: GroupProps;
|
|
12
|
-
groundRay: groundRayType;
|
|
13
|
-
refs: refsType;
|
|
14
|
-
callbacks?: callbackType;
|
|
15
|
-
isRider?: boolean;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export const InnerGroupRef = forwardRef((_, ref: Ref<THREE.Group>) => {
|
|
19
|
-
return <group ref={ref} visible={false} />;
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
export const CharacterInnerGroupRef = forwardRef(
|
|
23
|
-
(
|
|
24
|
-
{
|
|
25
|
-
prop,
|
|
26
|
-
groupProps,
|
|
27
|
-
groundRay,
|
|
28
|
-
refs,
|
|
29
|
-
callbacks,
|
|
30
|
-
isRider,
|
|
31
|
-
}: characterGltfType,
|
|
32
|
-
ref: Ref<THREE.Group>
|
|
33
|
-
) => {
|
|
34
|
-
const { characterGltf: gltf } = useContext(GaesupWorldContext);
|
|
35
|
-
const { materials, nodes } = gltf;
|
|
36
|
-
const { characterCollider, vehicleCollider } =
|
|
37
|
-
useContext(GaesupWorldContext);
|
|
38
|
-
|
|
39
|
-
initCallback({
|
|
40
|
-
prop,
|
|
41
|
-
callbacks,
|
|
42
|
-
outerGroupRef: refs.outerGroupRef,
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
playActions({
|
|
46
|
-
outerGroupRef: refs.outerGroupRef,
|
|
47
|
-
groundRay: groundRay,
|
|
48
|
-
isRider,
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
return (
|
|
52
|
-
<>
|
|
53
|
-
{nodes && materials && (
|
|
54
|
-
<group
|
|
55
|
-
receiveShadow
|
|
56
|
-
castShadow
|
|
57
|
-
{...groupProps}
|
|
58
|
-
position={[
|
|
59
|
-
0,
|
|
60
|
-
isRider
|
|
61
|
-
? vehicleCollider.vehicleSizeY / 2
|
|
62
|
-
: -characterCollider.height,
|
|
63
|
-
0,
|
|
64
|
-
]}
|
|
65
|
-
ref={ref}
|
|
66
|
-
>
|
|
67
|
-
{Object.values(nodes).find((node) => node.type === "Object3D") && (
|
|
68
|
-
<primitive
|
|
69
|
-
object={Object.values(nodes).find(
|
|
70
|
-
(node) => node.type === "Object3D"
|
|
71
|
-
)}
|
|
72
|
-
visible={false}
|
|
73
|
-
receiveShadow
|
|
74
|
-
castShadow
|
|
75
|
-
/>
|
|
76
|
-
)}
|
|
77
|
-
{Object.keys(nodes).map((name: string, key: number) => {
|
|
78
|
-
if (nodes[name].type === "SkinnedMesh") {
|
|
79
|
-
return (
|
|
80
|
-
<skinnedMesh
|
|
81
|
-
castShadow
|
|
82
|
-
receiveShadow
|
|
83
|
-
material={materials[name]}
|
|
84
|
-
geometry={nodes[name].geometry}
|
|
85
|
-
skeleton={(nodes[name] as THREE.SkinnedMesh).skeleton}
|
|
86
|
-
key={key}
|
|
87
|
-
/>
|
|
88
|
-
);
|
|
89
|
-
}
|
|
90
|
-
})}
|
|
91
|
-
</group>
|
|
92
|
-
)}
|
|
93
|
-
</>
|
|
94
|
-
);
|
|
95
|
-
}
|
|
96
|
-
);
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { Ref, forwardRef, useContext } from "react";
|
|
2
|
-
import { GaesupWorldContext } from "../../world/context";
|
|
3
|
-
|
|
4
|
-
export const VehicleInnerGroupRef = forwardRef((_, ref: Ref<THREE.Group>) => {
|
|
5
|
-
const { vehicleGltf: gltf } = useContext(GaesupWorldContext);
|
|
6
|
-
const { materials, nodes } = gltf;
|
|
7
|
-
return (
|
|
8
|
-
<>
|
|
9
|
-
{nodes && materials && (
|
|
10
|
-
<group receiveShadow castShadow rotation={[0, Math.PI, 0]} ref={ref}>
|
|
11
|
-
{Object.keys(nodes).map((name: string, key: number) => {
|
|
12
|
-
if (
|
|
13
|
-
nodes[name].type === "Mesh" ||
|
|
14
|
-
nodes[name].type === "SkinnedMesh"
|
|
15
|
-
) {
|
|
16
|
-
return (
|
|
17
|
-
<mesh
|
|
18
|
-
castShadow
|
|
19
|
-
receiveShadow
|
|
20
|
-
material={materials[name]}
|
|
21
|
-
geometry={nodes[name].geometry}
|
|
22
|
-
key={key}
|
|
23
|
-
/>
|
|
24
|
-
);
|
|
25
|
-
}
|
|
26
|
-
})}
|
|
27
|
-
</group>
|
|
28
|
-
)}
|
|
29
|
-
</>
|
|
30
|
-
);
|
|
31
|
-
});
|