gaesup-world 0.0.783 → 0.1.0

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.
Files changed (60) hide show
  1. package/README.md +24 -20
  2. package/dist/gaesup/animation/actions.d.ts +7 -4
  3. package/dist/gaesup/animation/actions.js +77 -75
  4. package/dist/gaesup/camera/control/normal.js +1 -1
  5. package/dist/gaesup/component/active/airplane/index.js +3 -4
  6. package/dist/gaesup/component/active/common/InnerGroupRef.js +5 -2
  7. package/dist/gaesup/component/active/common/RiderGroupRef.d.ts +7 -0
  8. package/dist/gaesup/component/active/common/RiderGroupRef.js +32 -0
  9. package/dist/gaesup/component/active/vehicle/index.js +3 -4
  10. package/dist/gaesup/component/index.js +1 -1
  11. package/dist/gaesup/component/passive/airplane/index.js +7 -7
  12. package/dist/gaesup/component/passive/airplane/type.d.ts +2 -0
  13. package/dist/gaesup/component/passive/common/RigidbodyRef.d.ts +2 -1
  14. package/dist/gaesup/component/passive/common/RigidbodyRef.js +3 -3
  15. package/dist/gaesup/component/passive/vehicle/index.js +7 -2
  16. package/dist/gaesup/component/passive/vehicle/type.d.ts +2 -0
  17. package/dist/gaesup/controller/index.d.ts +1 -0
  18. package/dist/gaesup/controller/index.js +7 -1
  19. package/dist/gaesup/controller/initialize/callback/index.js +3 -5
  20. package/dist/gaesup/controller/initialize/callback/type.d.ts +2 -1
  21. package/dist/gaesup/gaesupProps/index.d.ts +2 -1
  22. package/dist/gaesup/gaesupProps/index.js +7 -3
  23. package/dist/gaesup/hooks/useGaesupAnimation/index.d.ts +8 -0
  24. package/dist/gaesup/hooks/useGaesupAnimation/index.js +94 -0
  25. package/dist/gaesup/hooks/useRideable/index.d.ts +28 -0
  26. package/dist/gaesup/hooks/useRideable/index.js +198 -0
  27. package/dist/gaesup/hooks/useTeleport/index.d.ts +3 -0
  28. package/dist/gaesup/hooks/useTeleport/index.js +12 -0
  29. package/dist/gaesup/physics/airplane/direction.js +0 -1
  30. package/dist/gaesup/physics/airplane/index.js +2 -0
  31. package/dist/gaesup/physics/airplane/landing.d.ts +2 -0
  32. package/dist/gaesup/physics/airplane/landing.js +29 -0
  33. package/dist/gaesup/physics/check/index.js +4 -0
  34. package/dist/gaesup/physics/check/push.d.ts +2 -0
  35. package/dist/gaesup/physics/check/push.js +6 -0
  36. package/dist/gaesup/physics/check/riding.d.ts +2 -0
  37. package/dist/gaesup/physics/check/riding.js +7 -0
  38. package/dist/gaesup/physics/index.js +1 -1
  39. package/dist/gaesup/physics/vehicle/direction.js +0 -6
  40. package/dist/gaesup/physics/vehicle/index.js +2 -0
  41. package/dist/gaesup/physics/vehicle/landing.d.ts +2 -0
  42. package/dist/gaesup/physics/vehicle/landing.js +29 -0
  43. package/dist/gaesup/tools/jumpPortal/index.d.ts +1 -1
  44. package/dist/gaesup/tools/jumpPortal/index.js +6 -7
  45. package/dist/gaesup/tools/keyBoardToolTip/type.d.ts +2 -0
  46. package/dist/gaesup/tools/miniMap/index.js +22 -8
  47. package/dist/gaesup/tools/miniMap/type.d.ts +4 -1
  48. package/dist/gaesup/tools/rideable/index.d.ts +2 -8
  49. package/dist/gaesup/tools/rideable/index.js +37 -72
  50. package/dist/gaesup/tools/zoomButton/index.d.ts +7 -0
  51. package/dist/gaesup/tools/zoomButton/index.js +37 -13
  52. package/dist/gaesup/world/context/index.js +16 -12
  53. package/dist/gaesup/world/context/reducer.d.ts +3 -1
  54. package/dist/gaesup/world/context/type.d.ts +30 -5
  55. package/dist/gaesup/world/debug/index.js +1 -23
  56. package/dist/gaesup/world/initalize/index.d.ts +3 -1
  57. package/dist/gaesup/world/initalize/index.js +1 -1
  58. package/package.json +6 -5
  59. package/dist/gaesup/component/passive/vehicle/collider.d.ts +0 -6
  60. package/dist/gaesup/component/passive/vehicle/collider.js +0 -7
@@ -11,20 +11,24 @@ var __assign = (this && this.__assign) || function () {
11
11
  };
12
12
  import { jsx as _jsx } from "react/jsx-runtime";
13
13
  import { vec3 } from "@react-three/rapier";
14
- import { Suspense, useContext, useEffect, useRef } from "react";
14
+ import { Suspense, useContext, useEffect, useMemo, useRef } from "react";
15
15
  import * as THREE from "three";
16
16
  import { GaesupWorldContext, GaesupWorldDispatchContext, } from "../world/context/index.js";
17
17
  export function GaeSupProps(_a) {
18
- var text = _a.text, position = _a.position, children = _a.children;
18
+ var type = _a.type, text = _a.text, position = _a.position, children = _a.children;
19
19
  var groupRef = useRef(null);
20
20
  var minimap = useContext(GaesupWorldContext).minimap;
21
21
  var dispatch = useContext(GaesupWorldDispatchContext);
22
+ var groupComponent = useMemo(function () {
23
+ return (_jsx("group", { ref: groupRef, position: position, children: children }));
24
+ }, []);
22
25
  useEffect(function () {
23
26
  if (groupRef.current) {
24
27
  var box = new THREE.Box3().setFromObject(groupRef.current);
25
28
  var size = vec3(box.getSize(new THREE.Vector3())).clone();
26
29
  var center = vec3(box.getCenter(new THREE.Vector3())).clone();
27
30
  var obj = {
31
+ type: type ? type : "normal",
28
32
  text: text,
29
33
  size: size,
30
34
  center: center,
@@ -38,5 +42,5 @@ export function GaeSupProps(_a) {
38
42
  });
39
43
  }
40
44
  }, []);
41
- return (_jsx(Suspense, { fallback: null, children: _jsx("group", { ref: groupRef, position: position, children: children }) }));
45
+ return _jsx(Suspense, { fallback: null, children: groupComponent });
42
46
  }
@@ -0,0 +1,8 @@
1
+ import { animationAtomType } from "../../world/context/type";
2
+ export declare function useGaesupAnimation(): {
3
+ subscribe: ({ tag, condition, action, animationName, key, }: animationAtomType) => void;
4
+ subscribeAll: (props: animationAtomType[]) => void;
5
+ store: {};
6
+ unsubscribe: (tag: string) => void;
7
+ notify: () => string;
8
+ };
@@ -0,0 +1,94 @@
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
+ import { useContext } from "react";
13
+ import { GaesupWorldContext, GaesupWorldDispatchContext, } from "../../world/context";
14
+ export function useGaesupAnimation() {
15
+ var animations = useContext(GaesupWorldContext).animations;
16
+ var dispatch = useContext(GaesupWorldDispatchContext);
17
+ var getAnimationTag = function (tag) {
18
+ var animation = animations.store[tag];
19
+ if (!animation)
20
+ return { name: animations.default, isValid: false };
21
+ if (animation.condition()) {
22
+ return { name: animation.animationName, isValid: true };
23
+ }
24
+ else {
25
+ return { name: animations.default, isValid: false };
26
+ }
27
+ };
28
+ var notify = function () {
29
+ var tag = animations.default;
30
+ for (var _i = 0, _a = Object.keys(animations.store); _i < _a.length; _i++) {
31
+ var key = _a[_i];
32
+ var checked = getAnimationTag(key);
33
+ if (checked.isValid) {
34
+ tag = checked.name;
35
+ break;
36
+ }
37
+ }
38
+ animations.current = tag;
39
+ dispatch({
40
+ type: "update",
41
+ payload: {
42
+ animations: __assign({}, animations),
43
+ },
44
+ });
45
+ return tag;
46
+ };
47
+ var unsubscribe = function (tag) {
48
+ delete animations.store[tag];
49
+ dispatch({
50
+ type: "update",
51
+ payload: {
52
+ animations: __assign({}, animations),
53
+ },
54
+ });
55
+ };
56
+ var subscribe = function (_a) {
57
+ var tag = _a.tag, condition = _a.condition, action = _a.action, animationName = _a.animationName, key = _a.key;
58
+ animations.store[tag] = {
59
+ condition: condition,
60
+ action: action || (function () { }),
61
+ animationName: animationName || tag,
62
+ key: key || tag,
63
+ };
64
+ dispatch({
65
+ type: "update",
66
+ payload: {
67
+ animations: __assign({}, animations),
68
+ },
69
+ });
70
+ };
71
+ var subscribeAll = function (props) {
72
+ props.forEach(function (item) {
73
+ animations.store[item.tag] = {
74
+ condition: item.condition,
75
+ action: item.action,
76
+ animationName: item.animationName,
77
+ key: item.key,
78
+ };
79
+ });
80
+ dispatch({
81
+ type: "update",
82
+ payload: {
83
+ animations: __assign({}, animations),
84
+ },
85
+ });
86
+ };
87
+ return {
88
+ subscribe: subscribe,
89
+ subscribeAll: subscribeAll,
90
+ store: animations.store,
91
+ unsubscribe: unsubscribe,
92
+ notify: notify,
93
+ };
94
+ }
@@ -0,0 +1,28 @@
1
+ import { CollisionEnterPayload } from "@react-three/rapier";
2
+ import { rideableType } from "../../world/context/type";
3
+ /**
4
+ * Default rideable object properties.
5
+ * @type {Object}
6
+ */
7
+ export declare const rideableDefault: {
8
+ objectkey: any;
9
+ objectType: any;
10
+ isRiderOn: boolean;
11
+ url: any;
12
+ wheelUrl: any;
13
+ position: import("three").Vector3;
14
+ rotation: import("three").Euler;
15
+ offset: import("three").Vector3;
16
+ visible: boolean;
17
+ };
18
+ /**
19
+ * Custom hook for managing rideable objects.
20
+ * @returns {Object} An object containing functions to initialize, set, get, ride, and land rideable objects.
21
+ */
22
+ export declare function useRideable(): {
23
+ initRideable: (props: rideableType) => void;
24
+ setRideable: (props: rideableType) => void;
25
+ getRideable: (objectkey: string) => rideableType;
26
+ ride: (e: CollisionEnterPayload, props: rideableType) => Promise<void>;
27
+ landing: (objectkey: string) => void;
28
+ };
@@ -0,0 +1,198 @@
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
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
13
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
14
+ return new (P || (P = Promise))(function (resolve, reject) {
15
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
16
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
17
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
18
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
19
+ });
20
+ };
21
+ var __generator = (this && this.__generator) || function (thisArg, body) {
22
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
23
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
24
+ function verb(n) { return function (v) { return step([n, v]); }; }
25
+ function step(op) {
26
+ if (f) throw new TypeError("Generator is already executing.");
27
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
28
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
29
+ if (y = 0, t) op = [op[0] & 2, t.value];
30
+ switch (op[0]) {
31
+ case 0: case 1: t = op; break;
32
+ case 4: _.label++; return { value: op[1], done: false };
33
+ case 5: _.label++; y = op[1]; op = [0]; continue;
34
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
35
+ default:
36
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
37
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
38
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
39
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
40
+ if (t[2]) _.ops.pop();
41
+ _.trys.pop(); continue;
42
+ }
43
+ op = body.call(thisArg, _);
44
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
45
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
46
+ }
47
+ };
48
+ import { euler, vec3 } from "@react-three/rapier";
49
+ import { useContext } from "react";
50
+ import { V3 } from "../../utils";
51
+ import { GaesupWorldContext, GaesupWorldDispatchContext, } from "../../world/context";
52
+ /**
53
+ * Default rideable object properties.
54
+ * @type {Object}
55
+ */
56
+ export var rideableDefault = {
57
+ objectkey: null,
58
+ objectType: null,
59
+ isRiderOn: false,
60
+ url: null,
61
+ wheelUrl: null,
62
+ position: vec3(),
63
+ rotation: euler(),
64
+ offset: vec3(),
65
+ visible: true,
66
+ };
67
+ /**
68
+ * Custom hook for managing rideable objects.
69
+ * @returns {Object} An object containing functions to initialize, set, get, ride, and land rideable objects.
70
+ */
71
+ export function useRideable() {
72
+ var _this = this;
73
+ var worldContext = useContext(GaesupWorldContext);
74
+ var dispatch = useContext(GaesupWorldDispatchContext);
75
+ /**
76
+ * Initialize a rideable object with the provided properties.
77
+ * @param {rideableType} props - The properties of the rideable object to initialize.
78
+ */
79
+ var initRideable = function (props) {
80
+ worldContext.rideable[props.objectkey] = __assign(__assign({}, rideableDefault), props);
81
+ };
82
+ /**
83
+ * Set the properties of a rideable object.
84
+ * @param {rideableType} props - The properties to set for the rideable object.
85
+ */
86
+ var setRideable = function (props) {
87
+ worldContext.rideable[props.objectkey] = props;
88
+ };
89
+ /**
90
+ * Get the rideable object with the specified object key.
91
+ * @param {string} objectkey - The key of the rideable object to retrieve.
92
+ * @returns {rideableType} The rideable object with the specified key.
93
+ */
94
+ var getRideable = function (objectkey) {
95
+ return worldContext.rideable[objectkey];
96
+ };
97
+ /**
98
+ * Handle landing of a rideable object.
99
+ * @param {string} objectkey - The key of the rideable object to land.
100
+ */
101
+ var landing = function (objectkey) {
102
+ var activeState = worldContext.activeState, vehicleCollider = worldContext.vehicleCollider, airplaneCollider = worldContext.airplaneCollider;
103
+ worldContext.characterCollider.riderOffsetX = 0;
104
+ worldContext.characterCollider.riderOffsetY = 0;
105
+ worldContext.characterCollider.riderOffsetZ = 0;
106
+ worldContext.states.isRiding = false;
107
+ worldContext.rideable[objectkey].visible = true;
108
+ worldContext.rideable[objectkey].position.copy(activeState.position
109
+ .clone()
110
+ .add(worldContext.rideable[objectkey].objectType === "vehicle"
111
+ ? V3(vehicleCollider.vehicleSizeX, vehicleCollider.vehicleSizeY, vehicleCollider.vehicleSizeZ).multiplyScalar(1.5)
112
+ : V3(airplaneCollider.airplaneSizeX, airplaneCollider.airplaneSizeY, airplaneCollider.airplaneSizeZ).multiplyScalar(1.5)));
113
+ worldContext.rideable[objectkey].rotation.copy(activeState.euler.clone());
114
+ dispatch({
115
+ type: "update",
116
+ payload: {
117
+ rideable: __assign({}, worldContext.rideable),
118
+ states: __assign({}, worldContext.states),
119
+ characterCollider: __assign({}, worldContext.characterCollider),
120
+ },
121
+ });
122
+ };
123
+ /**
124
+ * Set the URL properties of a rideable object. (inner function)
125
+ * @param {rideableType} props - The properties containing URLs for the rideable object.
126
+ */
127
+ var setUrl = function (props) { return __awaiter(_this, void 0, void 0, function () {
128
+ return __generator(this, function (_a) {
129
+ if (props.objectType === "vehicle") {
130
+ worldContext.url.vehicleUrl = props.url;
131
+ worldContext.url.wheelUrl = props.wheelUrl || null;
132
+ }
133
+ else if (props.objectType === "airplane") {
134
+ worldContext.url.airplaneUrl = props.url;
135
+ }
136
+ dispatch({
137
+ type: "update",
138
+ payload: {
139
+ url: __assign({}, worldContext.url),
140
+ },
141
+ });
142
+ return [2 /*return*/];
143
+ });
144
+ }); };
145
+ /**
146
+ * Set the mode and riding state for a rideable object. (inner function)
147
+ * @param {rideableType} props - The properties of the rideable object to set mode and riding state.
148
+ */
149
+ var setModeAndRiding = function (props) { return __awaiter(_this, void 0, void 0, function () {
150
+ var _a, _b, _c;
151
+ return __generator(this, function (_d) {
152
+ worldContext.mode.type = props.objectType;
153
+ worldContext.states.isRiding = true;
154
+ worldContext.states.isRiderOn = props.isRiderOn;
155
+ worldContext.characterCollider.riderOffsetX = ((_a = props === null || props === void 0 ? void 0 : props.offset) === null || _a === void 0 ? void 0 : _a.x) || 0;
156
+ worldContext.characterCollider.riderOffsetY = ((_b = props === null || props === void 0 ? void 0 : props.offset) === null || _b === void 0 ? void 0 : _b.y) || 0;
157
+ worldContext.characterCollider.riderOffsetZ = ((_c = props === null || props === void 0 ? void 0 : props.offset) === null || _c === void 0 ? void 0 : _c.z) || 0;
158
+ worldContext.rideable[props.objectkey].visible = false;
159
+ dispatch({
160
+ type: "update",
161
+ payload: {
162
+ mode: __assign({}, worldContext.mode),
163
+ states: __assign({}, worldContext.states),
164
+ characterCollider: __assign({}, worldContext.characterCollider),
165
+ },
166
+ });
167
+ return [2 /*return*/];
168
+ });
169
+ }); };
170
+ /**
171
+ * Handle the ride event for a rideable object.
172
+ * @param {CollisionEnterPayload} e - The collision event payload.
173
+ * @param {rideableType} props - The properties of the rideable object.
174
+ */
175
+ var ride = function (e, props) { return __awaiter(_this, void 0, void 0, function () {
176
+ return __generator(this, function (_a) {
177
+ switch (_a.label) {
178
+ case 0:
179
+ if (!(e.other.rigidBodyObject.name === "character")) return [3 /*break*/, 3];
180
+ return [4 /*yield*/, setUrl(props)];
181
+ case 1:
182
+ _a.sent();
183
+ return [4 /*yield*/, setModeAndRiding(props)];
184
+ case 2:
185
+ _a.sent();
186
+ _a.label = 3;
187
+ case 3: return [2 /*return*/];
188
+ }
189
+ });
190
+ }); };
191
+ return {
192
+ initRideable: initRideable,
193
+ setRideable: setRideable,
194
+ getRideable: getRideable,
195
+ ride: ride,
196
+ landing: landing,
197
+ };
198
+ }
@@ -0,0 +1,3 @@
1
+ export declare function useTeleport(): {
2
+ Teleport: (position: THREE.Vector3) => void;
3
+ };
@@ -0,0 +1,12 @@
1
+ import { useContext } from "react";
2
+ import { GaesupWorldContext } from "../../world/context";
3
+ export function useTeleport() {
4
+ var refs = useContext(GaesupWorldContext).refs;
5
+ var Teleport = function (position) {
6
+ var _a, _b;
7
+ (_b = (_a = refs.rigidBodyRef) === null || _a === void 0 ? void 0 : _a.current) === null || _b === void 0 ? void 0 : _b.setTranslation(position, true);
8
+ };
9
+ return {
10
+ Teleport: Teleport,
11
+ };
12
+ }
@@ -60,5 +60,4 @@ export default function direction(prop) {
60
60
  activeState.rotation = innerGrounRefRotation.rotation;
61
61
  activeState.direction = front.multiply(V3(Math.sin(activeState.euler.y), -upDown, Math.cos(activeState.euler.y)));
62
62
  activeState.dir = activeState.direction.normalize();
63
- // activeState.euler = innerGroupRef.current.rotation;
64
63
  }
@@ -3,10 +3,12 @@ import direction from "./direction";
3
3
  import gravity from "./gravity";
4
4
  import impulse from "./impulse";
5
5
  import innerCalc from "./innerCalc";
6
+ import landing from "./landing";
6
7
  export default function airplaneCalculation(calcProp) {
7
8
  direction(calcProp);
8
9
  impulse(calcProp);
9
10
  damping(calcProp);
10
11
  gravity(calcProp);
12
+ landing(calcProp);
11
13
  innerCalc(calcProp);
12
14
  }
@@ -0,0 +1,2 @@
1
+ import { calcPropType } from "../type";
2
+ export default function landing(prop: calcPropType): void;
@@ -0,0 +1,29 @@
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
+ export default function landing(prop) {
13
+ var _a = prop.worldContext, states = _a.states, rideable = _a.rideable, mode = _a.mode, dispatch = prop.dispatch;
14
+ var isLanding = states.isLanding;
15
+ if (isLanding) {
16
+ rideable.objectType = null;
17
+ rideable.key = null;
18
+ mode.type = "character";
19
+ states.isLanding = false;
20
+ states.isRiding = false;
21
+ }
22
+ dispatch({
23
+ type: "update",
24
+ payload: {
25
+ mode: __assign({}, mode),
26
+ rideable: __assign({}, rideable),
27
+ },
28
+ });
29
+ }
@@ -1,5 +1,7 @@
1
1
  import ground from "./ground";
2
2
  import moving from "./moving";
3
+ import push from "./push";
4
+ import riding from "./riding";
3
5
  import rotate from "./rotate";
4
6
  import slope from "./slope";
5
7
  export default function check(calcProp) {
@@ -7,4 +9,6 @@ export default function check(calcProp) {
7
9
  slope(calcProp);
8
10
  moving(calcProp);
9
11
  rotate(calcProp);
12
+ push(calcProp);
13
+ riding(calcProp);
10
14
  }
@@ -0,0 +1,2 @@
1
+ import { calcPropType } from "../type";
2
+ export default function push(prop: calcPropType): void;
@@ -0,0 +1,6 @@
1
+ export default function push(prop) {
2
+ var _a = prop.worldContext, states = _a.states, joystick = _a.joystick, mode = _a.mode, control = _a.control;
3
+ Object.keys(control).forEach(function (key) {
4
+ states.isPush[key] = control[key];
5
+ });
6
+ }
@@ -0,0 +1,2 @@
1
+ import { calcPropType } from "../type";
2
+ export default function riding(prop: calcPropType): void;
@@ -0,0 +1,7 @@
1
+ export default function riding(prop) {
2
+ var _a = prop.worldContext, states = _a.states, rideable = _a.rideable, mode = _a.mode;
3
+ var isRiding = states.isRiding;
4
+ if (isRiding && states.isPush["keyR"]) {
5
+ states.isLanding = true;
6
+ }
7
+ }
@@ -29,7 +29,7 @@ export default function calculation(prop) {
29
29
  var rigidBodyRef = prop.rigidBodyRef;
30
30
  if (rigidBodyRef.current) {
31
31
  rigidBodyRef.current.lockRotations(true, true);
32
- rigidBodyRef.current.setTranslation(activeState.position.clone().add(V3(0, 5, 0)), true);
32
+ rigidBodyRef.current.setTranslation(activeState.position.clone().add(V3(0, 2, 0)), true);
33
33
  }
34
34
  }, [mode.type]);
35
35
  useFrame(function (state, delta) {
@@ -7,12 +7,6 @@ export function joystick(prop) {
7
7
  if (joystick.joyStickOrigin.isCenter)
8
8
  return front;
9
9
  activeState.euler.y = Math.PI / 2 - joystick.joyStickOrigin.angle;
10
- // const _euler = activeState.euler.clone();
11
- // const __euler = activeState.euler.clone();
12
- // __euler.y = Math.PI / 2 - joystick.joyStickOrigin.angle;
13
- // activeState.euler.setFromQuaternion(
14
- // quat().setFromEuler(_euler).slerp(quat().setFromEuler(__euler), 1)
15
- // );
16
10
  return front;
17
11
  }
18
12
  export function normal(prop) {
@@ -2,9 +2,11 @@ import damping from "./damping";
2
2
  import direction from "./direction";
3
3
  import impulse from "./impulse";
4
4
  import innerCalc from "./innerCalc";
5
+ import landing from "./landing";
5
6
  export default function vehicleCalculation(calcProp) {
6
7
  direction(calcProp);
7
8
  impulse(calcProp);
8
9
  damping(calcProp);
10
+ landing(calcProp);
9
11
  innerCalc(calcProp);
10
12
  }
@@ -0,0 +1,2 @@
1
+ import { calcPropType } from "../type";
2
+ export default function landing(prop: calcPropType): void;
@@ -0,0 +1,29 @@
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
+ export default function landing(prop) {
13
+ var _a = prop.worldContext, states = _a.states, rideable = _a.rideable, mode = _a.mode, dispatch = prop.dispatch;
14
+ var isLanding = states.isLanding;
15
+ if (isLanding) {
16
+ rideable.objectType = null;
17
+ rideable.key = null;
18
+ mode.type = "character";
19
+ states.isLanding = false;
20
+ states.isRiding = false;
21
+ }
22
+ dispatch({
23
+ type: "update",
24
+ payload: {
25
+ mode: __assign({}, mode),
26
+ rideable: __assign({}, rideable),
27
+ },
28
+ });
29
+ }
@@ -1,3 +1,3 @@
1
1
  import { portalType } from "../../world/context/type";
2
2
  import "./style.css";
3
- export declare function JumpPortal(props: portalType): import("react/jsx-runtime").JSX.Element;
3
+ export declare function JumpPortal({ text, position, jumpPortalStlye }: portalType): import("react/jsx-runtime").JSX.Element;
@@ -1,11 +1,10 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { useContext } from "react";
3
- import { GaesupWorldContext } from "../../world/context";
2
+ import { useTeleport } from "../../hooks/useTeleport";
4
3
  import "./style.css";
5
- export function JumpPortal(props) {
6
- var refs = useContext(GaesupWorldContext).refs;
4
+ export function JumpPortal(_a) {
5
+ var text = _a.text, position = _a.position, jumpPortalStlye = _a.jumpPortalStlye;
6
+ var Teleport = useTeleport().Teleport;
7
7
  return (_jsx("div", { className: "jumpPortal", onClick: function () {
8
- var _a, _b;
9
- (_b = (_a = refs.rigidBodyRef) === null || _a === void 0 ? void 0 : _a.current) === null || _b === void 0 ? void 0 : _b.setTranslation(props.position, true);
10
- }, style: props.jumpPortalStlye, children: props.text }));
8
+ Teleport(position);
9
+ }, style: jumpPortalStlye, children: text }));
11
10
  }
@@ -2,6 +2,8 @@ import { CSSProperties } from "react";
2
2
  export type keyboardMapType = {
3
3
  name: string;
4
4
  keys: string[];
5
+ label?: string;
6
+ match?: string;
5
7
  }[];
6
8
  export type keyMapItemType = {
7
9
  name: string;
@@ -35,17 +35,31 @@ export function MiniMap(props) {
35
35
  upscale();
36
36
  else
37
37
  downscale();
38
- }, children: [_jsx("div", { className: "minimapOuter", style: objectStyle }), _jsxs("div", { className: "minimapInner", style: __assign({
39
- // transform: props.blockRotate
40
- // ? `translate(-50%, -50%) rotate(180deg) `
41
- // : `translate(-50%, -50%) rotate(${
42
- // (activeState.euler.y * 180) / Math.PI + 180
43
- // }deg) `,
44
- transform: "translate(-50%, -50%) rotate(180deg)" }, innerStyle), children: [_jsx("div", { className: "east direction", style: __assign({ transform: "translate(-50%, 50%) rotate(180deg)" }, directionStyle), children: "E" }), _jsx("div", { className: "west direction", style: __assign({ transform: "translate(50%, 50%) rotate(180deg)" }, directionStyle), children: "W" }), _jsx("div", { className: "south direction", style: __assign({ transform: "translate(-50%, 50%) rotate(180deg)" }, directionStyle), children: "S" }), _jsx("div", { className: "north direction", style: __assign({ transform: "translate(-50%, -50%) rotate(180deg)" }, directionStyle), children: "N" }), Object.values(minimap.props).map(function (_a, key) {
38
+ }, children: [_jsx("div", { className: "minimapOuter", style: objectStyle }), _jsxs("div", { className: "minimapInner", style: __assign({ transform: props.blockRotate || mode.control === "normal"
39
+ ? "translate(-50%, -50%) rotate(180deg) "
40
+ : "translate(-50%, -50%) rotate(".concat((activeState.euler.y * 180) / Math.PI + 180, "deg) ") }, innerStyle), children: [_jsx("div", { className: "east direction", style: __assign({ transform: props.blockRotate || mode.control === "normal"
41
+ ? "translate(-50%, -50%) rotate(180deg) "
42
+ : "translate(-50%, -50%) rotate(-".concat((activeState.euler.y * 180) / Math.PI + 180, "deg) ") }, directionStyle), children: "E" }), _jsx("div", { className: "west direction", style: __assign({ transform: props.blockRotate || mode.control === "normal"
43
+ ? "translate(50%, -50%) rotate(180deg) "
44
+ : "translate(50%, -50%) rotate(-".concat((activeState.euler.y * 180) / Math.PI + 180, "deg) ") }, directionStyle), children: "W" }), _jsx("div", { className: "south direction", style: __assign({ transform: props.blockRotate || mode.control === "normal"
45
+ ? "translate(-50%, 50%) rotate(180deg) "
46
+ : "translate(-50%, 50%) rotate(-".concat((activeState.euler.y * 180) / Math.PI + 180, "deg) ") }, directionStyle), children: "S" }), _jsx("div", { className: "north direction", style: __assign({ transform: props.blockRotate || mode.control === "normal"
47
+ ? "translate(-50%, -50%) rotate(180deg) "
48
+ : "translate(-50%, -50%) rotate(-".concat((activeState.euler.y * 180) / Math.PI + 180, "deg) ") }, directionStyle), children: "N" }), Object.values(minimap.props).map(function (_a, key) {
45
49
  var center = _a.center, size = _a.size, text = _a.text;
46
50
  var X = (center.x - activeState.position.x) * scale;
47
51
  var Z = (center.z - activeState.position.z) * scale;
48
- return (_jsx("div", { className: "minimapObject", style: __assign({ width: "".concat(size.x * scale, "rem"), height: "".concat(size.z * scale, "rem"), top: "50%", left: "50%", transform: "translate(-50%, -50%) translate(".concat(-X, "rem, ").concat(-Z, "rem)"), transformOrigin: "50% 50%" }, objectStyle), children: text && (_jsx("div", { className: "text", style: __assign(__assign({}, textStyle), { transform: "rotate(-180deg)" }), children: text })) }, key));
52
+ return (_jsxs("div", { children: [_jsx("div", { className: "minimapObject", style: __assign({ width: "".concat(size.x * scale, "rem"), height: "".concat(size.z * scale, "rem"), top: "50%", left: "50%", transform: "translate(-50.1%, -50.1%) translate(".concat(-X, "rem, ").concat(-Z, "rem)"), transformOrigin: "50% 50%", zIndex: 1 + key }, objectStyle) }, key), _jsx("div", { className: "textObject", style: {
53
+ width: "".concat(size.x * scale, "rem"),
54
+ height: "".concat(size.z * scale, "rem"),
55
+ top: "50.1%",
56
+ left: "50.1%",
57
+ transform: "translate(-50.1%, -50.1%) translate(".concat(-X, "rem, ").concat(-Z, "rem)"),
58
+ transformOrigin: "50.1% 50.1%",
59
+ zIndex: 1001 + key,
60
+ }, children: text && (_jsx("div", { className: "text", style: __assign(__assign({}, textStyle), { zIndex: 1001 + key, transform: props.blockRotate || mode.control === "normal"
61
+ ? " rotate(180deg) "
62
+ : " rotate(-".concat((activeState.euler.y * 180) / Math.PI + 180, "deg) ") }), children: text })) })] }, key));
49
63
  }), _jsx("div", { className: "avatar", style: avatarStyle })] }), !props.blockScaleControl && (_jsxs("div", { className: "scale", style: scaleStyle, children: [_jsx("div", { className: "plusMinus", style: plusMinusStyle, onClick: function () {
50
64
  if (props.blockScale)
51
65
  return;
@@ -1,9 +1,12 @@
1
- import { CSSProperties } from "react";
1
+ import { CSSProperties, ReactElement } from "react";
2
2
  import * as THREE from "three";
3
3
  export type minimapPropsType = {
4
+ type: "normal" | "ground";
4
5
  text?: string;
5
6
  center: THREE.Vector3;
6
7
  size: THREE.Vector3;
8
+ children?: ReactElement;
9
+ position?: THREE.Vector3;
7
10
  };
8
11
  export type minimapInnerType = {
9
12
  props: {