gaesup-world 0.9.57 → 0.9.58
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.
|
@@ -1,18 +1,16 @@
|
|
|
1
|
-
import { useContext } from "react";
|
|
2
1
|
import * as THREE from "three";
|
|
3
|
-
import { GaesupWorldContext } from "../../world/context";
|
|
4
2
|
|
|
5
3
|
export function useTeleport() {
|
|
6
|
-
const worldContext = useContext(GaesupWorldContext);
|
|
4
|
+
// const worldContext = useContext(GaesupWorldContext);
|
|
7
5
|
|
|
8
6
|
const Teleport = (position: THREE.Vector3) => {
|
|
9
|
-
if (
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
)
|
|
15
|
-
|
|
7
|
+
// if (
|
|
8
|
+
// worldContext &&
|
|
9
|
+
// worldContext?.refs &&
|
|
10
|
+
// worldContext?.refs?.rigidBodyRef &&
|
|
11
|
+
// worldContext?.refs?.rigidBodyRef?.current
|
|
12
|
+
// )
|
|
13
|
+
// worldContext.refs.rigidBodyRef.current.setTranslation(position, true);
|
|
16
14
|
};
|
|
17
15
|
|
|
18
16
|
return {
|
|
@@ -1,80 +1,72 @@
|
|
|
1
1
|
// Rideable.tsx
|
|
2
|
-
import { CollisionEnterPayload, euler } from "@react-three/rapier";
|
|
3
|
-
import { useContext, useEffect, useState } from "react";
|
|
4
|
-
import * as THREE from "three";
|
|
5
|
-
import { PassiveAirplane } from "../../component/passive/airplane";
|
|
6
|
-
import { PassiveVehicle } from "../../component/passive/vehicle";
|
|
7
|
-
import { useRideable } from "../../hooks/useRideable";
|
|
8
|
-
import { V3 } from "../../utils";
|
|
9
|
-
import { GaesupWorldContext } from "../../world/context";
|
|
10
2
|
import { rideablePropType } from "./type";
|
|
11
3
|
|
|
12
4
|
export function Rideable(props: rideablePropType) {
|
|
13
|
-
const { states, rideable } = useContext(GaesupWorldContext);
|
|
14
|
-
const { initRideable, ride, landing } = useRideable();
|
|
15
|
-
const [_rideable] = useState<{
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}>({
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
useEffect(() => {
|
|
24
|
-
|
|
25
|
-
}, []);
|
|
26
|
-
|
|
27
|
-
useEffect(() => {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}, [states?.isRiding]);
|
|
36
|
-
|
|
37
|
-
const onIntersectionEnter = async (e: CollisionEnterPayload) => {
|
|
38
|
-
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
return (
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
);
|
|
5
|
+
// const { states, rideable } = useContext(GaesupWorldContext);
|
|
6
|
+
// const { initRideable, ride, landing } = useRideable();
|
|
7
|
+
// const [_rideable] = useState<{
|
|
8
|
+
// position: THREE.Vector3;
|
|
9
|
+
// rotation: THREE.Euler;
|
|
10
|
+
// }>({
|
|
11
|
+
// position: props.position || V3(0, 0, 0),
|
|
12
|
+
// rotation: props.rotation || euler(),
|
|
13
|
+
// });
|
|
14
|
+
//
|
|
15
|
+
// useEffect(() => {
|
|
16
|
+
// initRideable(props);
|
|
17
|
+
// }, []);
|
|
18
|
+
//
|
|
19
|
+
// useEffect(() => {
|
|
20
|
+
// if (
|
|
21
|
+
// states?.isRiding &&
|
|
22
|
+
// rideable[props.objectkey] &&
|
|
23
|
+
// !rideable[props.objectkey].visible
|
|
24
|
+
// ) {
|
|
25
|
+
// landing(props.objectkey);
|
|
26
|
+
// }
|
|
27
|
+
// }, [states?.isRiding]);
|
|
28
|
+
//
|
|
29
|
+
// const onIntersectionEnter = async (e: CollisionEnterPayload) => {
|
|
30
|
+
// await ride(e, props);
|
|
31
|
+
// };
|
|
32
|
+
//
|
|
33
|
+
// return (
|
|
34
|
+
// <>
|
|
35
|
+
// {rideable?.[props.objectkey]?.visible && (
|
|
36
|
+
// <group userData={{ intangible: true }}>
|
|
37
|
+
// {props.objectType === "vehicle" && (
|
|
38
|
+
// <PassiveVehicle
|
|
39
|
+
// controllerOptions={props.controllerOptions}
|
|
40
|
+
// position={_rideable.position}
|
|
41
|
+
// rotation={_rideable.rotation}
|
|
42
|
+
// currentAnimation={"idle"}
|
|
43
|
+
// url={props.url}
|
|
44
|
+
// wheelUrl={props.wheelUrl}
|
|
45
|
+
// ridingUrl={props.ridingUrl}
|
|
46
|
+
// offset={props.offset}
|
|
47
|
+
// enableRiding={props.enableRiding}
|
|
48
|
+
// rigidBodyProps={props.rigidBodyProps}
|
|
49
|
+
// sensor={true}
|
|
50
|
+
// onIntersectionEnter={onIntersectionEnter}
|
|
51
|
+
// />
|
|
52
|
+
// )}
|
|
53
|
+
// {props.objectType === "airplane" && (
|
|
54
|
+
// <PassiveAirplane
|
|
55
|
+
// controllerOptions={props.controllerOptions}
|
|
56
|
+
// position={_rideable.position.clone()}
|
|
57
|
+
// rotation={_rideable.rotation.clone()}
|
|
58
|
+
// currentAnimation={"idle"}
|
|
59
|
+
// url={props.url}
|
|
60
|
+
// ridingUrl={props.ridingUrl}
|
|
61
|
+
// offset={props.offset}
|
|
62
|
+
// enableRiding={props.enableRiding}
|
|
63
|
+
// rigidBodyProps={props.rigidBodyProps}
|
|
64
|
+
// sensor={true}
|
|
65
|
+
// onIntersectionEnter={onIntersectionEnter}
|
|
66
|
+
// />
|
|
67
|
+
// )}
|
|
68
|
+
// </group>
|
|
69
|
+
// )}
|
|
70
|
+
// </>
|
|
71
|
+
// );
|
|
80
72
|
}
|