gaesup-world 0.2.24 → 0.2.26
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 +44 -0
- package/dist/gaesup/animation/actions.js +103 -0
- package/dist/gaesup/camera/control/normal.d.ts +4 -0
- package/dist/gaesup/camera/control/normal.js +18 -0
- package/dist/gaesup/camera/control/orbit.d.ts +4 -0
- package/dist/gaesup/camera/control/orbit.js +22 -0
- package/dist/gaesup/camera/detector/index.d.ts +2 -0
- package/dist/gaesup/camera/detector/index.js +25 -0
- package/dist/gaesup/camera/index.d.ts +8 -0
- package/dist/gaesup/camera/index.js +139 -0
- package/dist/gaesup/camera/type.d.ts +13 -0
- package/dist/gaesup/camera/type.js +1 -0
- package/dist/gaesup/component/active/airplane/index.d.ts +11 -0
- package/dist/gaesup/component/active/airplane/index.js +6 -0
- package/dist/gaesup/component/active/character/index.d.ts +7 -0
- package/dist/gaesup/component/active/character/index.js +34 -0
- package/dist/gaesup/component/active/vehicle/index.d.ts +12 -0
- package/dist/gaesup/component/active/vehicle/index.js +31 -0
- package/dist/gaesup/component/index.d.ts +7 -0
- package/dist/gaesup/component/index.js +19 -0
- package/dist/gaesup/component/inner/airplane/index.d.ts +2 -0
- package/dist/gaesup/component/inner/airplane/index.js +16 -0
- package/dist/gaesup/component/inner/character/index.d.ts +25 -0
- package/dist/gaesup/component/inner/character/index.js +28 -0
- package/dist/gaesup/component/inner/common/InnerGroupRef.d.ts +10 -0
- package/dist/gaesup/component/inner/common/InnerGroupRef.js +29 -0
- package/dist/gaesup/component/inner/common/OuterGroupRef.d.ts +4 -0
- package/dist/gaesup/component/inner/common/OuterGroupRef.js +6 -0
- package/dist/gaesup/component/inner/common/RigidbodyRef.d.ts +12 -0
- package/dist/gaesup/component/inner/common/RigidbodyRef.js +7 -0
- package/dist/gaesup/component/inner/common/setGroundRay.d.ts +9 -0
- package/dist/gaesup/component/inner/common/setGroundRay.js +14 -0
- package/dist/gaesup/component/inner/common/type.d.ts +20 -0
- package/dist/gaesup/component/inner/common/type.js +1 -0
- package/dist/gaesup/component/inner/rider/index.d.ts +11 -0
- package/dist/gaesup/component/inner/rider/index.js +31 -0
- package/dist/gaesup/component/inner/vehicle/collider.d.ts +10 -0
- package/dist/gaesup/component/inner/vehicle/collider.js +19 -0
- package/dist/gaesup/component/inner/vehicle/index.d.ts +2 -0
- package/dist/gaesup/component/inner/vehicle/index.js +17 -0
- package/dist/gaesup/component/inner/vehicle/wheels.d.ts +7 -0
- package/dist/gaesup/component/inner/vehicle/wheels.js +64 -0
- package/dist/gaesup/component/passive/airplane/index.d.ts +13 -0
- package/dist/gaesup/component/passive/airplane/index.js +40 -0
- package/dist/gaesup/component/passive/character/index.d.ts +10 -0
- package/dist/gaesup/component/passive/character/index.js +46 -0
- package/dist/gaesup/component/passive/type.d.ts +20 -0
- package/dist/gaesup/component/passive/type.js +1 -0
- package/dist/gaesup/component/passive/vehicle/index.d.ts +13 -0
- package/dist/gaesup/component/passive/vehicle/index.js +17 -0
- package/dist/gaesup/component/type.d.ts +17 -0
- package/dist/gaesup/component/type.js +1 -0
- package/dist/gaesup/controller/context/index.d.ts +49 -0
- package/dist/gaesup/controller/context/index.js +59 -0
- package/dist/gaesup/controller/context/reducer.d.ts +12 -0
- package/dist/gaesup/controller/context/reducer.js +21 -0
- package/dist/gaesup/controller/context/type.d.ts +38 -0
- package/dist/gaesup/controller/context/type.js +1 -0
- package/dist/gaesup/controller/debug/airplane.d.ts +71 -0
- package/dist/gaesup/controller/debug/airplane.js +71 -0
- package/dist/gaesup/controller/debug/character.d.ts +27 -0
- package/dist/gaesup/controller/debug/character.js +27 -0
- package/dist/gaesup/controller/debug/index.d.ts +6 -0
- package/dist/gaesup/controller/debug/index.js +49 -0
- package/dist/gaesup/controller/debug/vehicle.d.ts +27 -0
- package/dist/gaesup/controller/debug/vehicle.js +27 -0
- package/dist/gaesup/controller/index.d.ts +3 -0
- package/dist/gaesup/controller/index.js +74 -0
- package/dist/gaesup/controller/initialize/callback/index.d.ts +2 -0
- package/dist/gaesup/controller/initialize/callback/index.js +62 -0
- package/dist/gaesup/controller/initialize/callback/type.d.ts +27 -0
- package/dist/gaesup/controller/initialize/callback/type.js +1 -0
- package/dist/gaesup/controller/initialize/index.d.ts +10 -0
- package/dist/gaesup/controller/initialize/index.js +75 -0
- package/dist/gaesup/controller/type.d.ts +85 -0
- package/dist/gaesup/controller/type.js +1 -0
- package/dist/gaesup/gaesupProps/index.d.ts +7 -0
- package/dist/gaesup/gaesupProps/index.js +46 -0
- package/dist/gaesup/hooks/useGaesupAnimation/index.d.ts +10 -0
- package/dist/gaesup/hooks/useGaesupAnimation/index.js +95 -0
- package/dist/gaesup/hooks/useGaesupController/index.d.ts +10 -0
- package/dist/gaesup/hooks/useGaesupController/index.js +14 -0
- package/dist/gaesup/hooks/useGaesupGltf/index.d.ts +25 -0
- package/dist/gaesup/hooks/useGaesupGltf/index.js +73 -0
- package/dist/gaesup/hooks/useJoyStick/index.d.ts +39 -0
- package/dist/gaesup/hooks/useJoyStick/index.js +61 -0
- package/dist/gaesup/hooks/usePushKey/index.d.ts +3 -0
- package/dist/gaesup/hooks/usePushKey/index.js +29 -0
- package/dist/gaesup/hooks/useRideable/index.d.ts +28 -0
- package/dist/gaesup/hooks/useRideable/index.js +199 -0
- package/dist/gaesup/hooks/useTeleport/index.d.ts +3 -0
- package/dist/gaesup/hooks/useTeleport/index.js +12 -0
- package/dist/gaesup/physics/airplane/damping.d.ts +2 -0
- package/dist/gaesup/physics/airplane/damping.js +5 -0
- package/dist/gaesup/physics/airplane/direction.d.ts +2 -0
- package/dist/gaesup/physics/airplane/direction.js +65 -0
- package/dist/gaesup/physics/airplane/gravity.d.ts +14 -0
- package/dist/gaesup/physics/airplane/gravity.js +18 -0
- package/dist/gaesup/physics/airplane/impulse.d.ts +16 -0
- package/dist/gaesup/physics/airplane/impulse.js +31 -0
- package/dist/gaesup/physics/airplane/index.d.ts +2 -0
- package/dist/gaesup/physics/airplane/index.js +14 -0
- package/dist/gaesup/physics/airplane/innerCalc.d.ts +2 -0
- package/dist/gaesup/physics/airplane/innerCalc.js +27 -0
- package/dist/gaesup/physics/airplane/landing.d.ts +2 -0
- package/dist/gaesup/physics/airplane/landing.js +29 -0
- package/dist/gaesup/physics/character/direction.d.ts +23 -0
- package/dist/gaesup/physics/character/direction.js +55 -0
- package/dist/gaesup/physics/character/impulse.d.ts +2 -0
- package/dist/gaesup/physics/character/impulse.js +43 -0
- package/dist/gaesup/physics/character/index.d.ts +2 -0
- package/dist/gaesup/physics/character/index.js +8 -0
- package/dist/gaesup/physics/character/innerCalc.d.ts +2 -0
- package/dist/gaesup/physics/character/innerCalc.js +31 -0
- package/dist/gaesup/physics/check/ground.d.ts +2 -0
- package/dist/gaesup/physics/check/ground.js +15 -0
- package/dist/gaesup/physics/check/index.d.ts +2 -0
- package/dist/gaesup/physics/check/index.js +12 -0
- package/dist/gaesup/physics/check/moving.d.ts +2 -0
- package/dist/gaesup/physics/check/moving.js +16 -0
- package/dist/gaesup/physics/check/push.d.ts +2 -0
- package/dist/gaesup/physics/check/push.js +6 -0
- package/dist/gaesup/physics/check/riding.d.ts +2 -0
- package/dist/gaesup/physics/check/riding.js +7 -0
- package/dist/gaesup/physics/check/rotate.d.ts +2 -0
- package/dist/gaesup/physics/check/rotate.js +8 -0
- package/dist/gaesup/physics/index.d.ts +2 -0
- package/dist/gaesup/physics/index.js +58 -0
- package/dist/gaesup/physics/type.d.ts +36 -0
- package/dist/gaesup/physics/type.js +1 -0
- package/dist/gaesup/physics/vehicle/damping.d.ts +2 -0
- package/dist/gaesup/physics/vehicle/damping.js +6 -0
- package/dist/gaesup/physics/vehicle/direction.d.ts +4 -0
- package/dist/gaesup/physics/vehicle/direction.js +30 -0
- package/dist/gaesup/physics/vehicle/impulse.d.ts +16 -0
- package/dist/gaesup/physics/vehicle/impulse.js +40 -0
- package/dist/gaesup/physics/vehicle/index.d.ts +2 -0
- package/dist/gaesup/physics/vehicle/index.js +12 -0
- package/dist/gaesup/physics/vehicle/innerCalc.d.ts +2 -0
- package/dist/gaesup/physics/vehicle/innerCalc.js +24 -0
- package/dist/gaesup/physics/vehicle/landing.d.ts +2 -0
- package/dist/gaesup/physics/vehicle/landing.js +29 -0
- package/dist/gaesup/tools/gameBoy/GameBoyButton.d.ts +9 -0
- package/dist/gaesup/tools/gameBoy/GameBoyButton.js +16 -0
- package/dist/gaesup/tools/gameBoy/index.d.ts +8 -0
- package/dist/gaesup/tools/gameBoy/index.js +22 -0
- package/dist/gaesup/tools/gameBoy/type.d.ts +4 -0
- package/dist/gaesup/tools/gameBoy/type.js +1 -0
- package/dist/gaesup/tools/gamePad/GamePadButton.d.ts +8 -0
- package/dist/gaesup/tools/gamePad/GamePadButton.js +21 -0
- package/dist/gaesup/tools/gamePad/index.d.ts +6 -0
- package/dist/gaesup/tools/gamePad/index.js +32 -0
- package/dist/gaesup/tools/gamePad/type.d.ts +6 -0
- package/dist/gaesup/tools/gamePad/type.js +1 -0
- package/dist/gaesup/tools/joyStick/index.d.ts +6 -0
- package/dist/gaesup/tools/joyStick/index.js +169 -0
- package/dist/gaesup/tools/joyStick/type.d.ts +19 -0
- package/dist/gaesup/tools/joyStick/type.js +1 -0
- package/dist/gaesup/tools/jumpPortal/index.d.ts +16 -0
- package/dist/gaesup/tools/jumpPortal/index.js +18 -0
- package/dist/gaesup/tools/keyBoardToolTip/constant.d.ts +402 -0
- package/dist/gaesup/tools/keyBoardToolTip/constant.js +122 -0
- package/dist/gaesup/tools/keyBoardToolTip/default.d.ts +10 -0
- package/dist/gaesup/tools/keyBoardToolTip/default.js +12 -0
- package/dist/gaesup/tools/keyBoardToolTip/index.d.ts +3 -0
- package/dist/gaesup/tools/keyBoardToolTip/index.js +70 -0
- package/dist/gaesup/tools/keyBoardToolTip/type.d.ts +37 -0
- package/dist/gaesup/tools/keyBoardToolTip/type.js +1 -0
- package/dist/gaesup/tools/miniMap/default.d.ts +9 -0
- package/dist/gaesup/tools/miniMap/default.js +9 -0
- package/dist/gaesup/tools/miniMap/index.d.ts +3 -0
- package/dist/gaesup/tools/miniMap/index.js +72 -0
- package/dist/gaesup/tools/miniMap/type.d.ts +25 -0
- package/dist/gaesup/tools/miniMap/type.js +1 -0
- package/dist/gaesup/tools/rideable/index.d.ts +3 -0
- package/dist/gaesup/tools/rideable/index.js +79 -0
- package/dist/gaesup/tools/type.d.ts +2 -0
- package/dist/gaesup/tools/type.js +1 -0
- package/dist/gaesup/tools/zoomButton/index.d.ts +18 -0
- package/dist/gaesup/tools/zoomButton/index.js +146 -0
- package/dist/gaesup/utils/context.d.ts +2 -0
- package/dist/gaesup/utils/context.js +3 -0
- package/dist/gaesup/utils/debug.d.ts +29 -0
- package/dist/gaesup/utils/debug.js +36 -0
- package/dist/gaesup/utils/index.d.ts +3 -0
- package/dist/gaesup/utils/index.js +3 -0
- package/dist/gaesup/utils/ray.d.ts +7 -0
- package/dist/gaesup/utils/ray.js +6 -0
- package/dist/gaesup/utils/ref.d.ts +2 -0
- package/dist/gaesup/utils/ref.js +16 -0
- package/dist/gaesup/utils/type.d.ts +5 -0
- package/dist/gaesup/utils/type.js +1 -0
- package/dist/gaesup/utils/vector.d.ts +10 -0
- package/dist/gaesup/utils/vector.js +33 -0
- package/dist/gaesup/world/context/index.d.ts +6 -0
- package/dist/gaesup/world/context/index.js +117 -0
- package/dist/gaesup/world/context/reducer.d.ts +29 -0
- package/dist/gaesup/world/context/reducer.js +21 -0
- package/dist/gaesup/world/context/type.d.ts +169 -0
- package/dist/gaesup/world/context/type.js +1 -0
- package/dist/gaesup/world/debug/cameraOption.d.ts +47 -0
- package/dist/gaesup/world/debug/cameraOption.js +47 -0
- package/dist/gaesup/world/debug/index.d.ts +6 -0
- package/dist/gaesup/world/debug/index.js +32 -0
- package/dist/gaesup/world/debug/mode.d.ts +10 -0
- package/dist/gaesup/world/debug/mode.js +10 -0
- package/dist/gaesup/world/index.d.ts +3 -0
- package/dist/gaesup/world/index.js +9 -0
- package/dist/gaesup/world/initalize/index.d.ts +35 -0
- package/dist/gaesup/world/initalize/index.js +62 -0
- package/dist/gaesup/world/type.d.ts +19 -0
- package/dist/gaesup/world/type.js +1 -0
- package/dist/index.d.ts +23 -0
- package/index.ts +29 -0
- package/package.json +2 -5
- package/yarn-error.log +12152 -0
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { Collider, Ray, RayColliderToi } from "@dimforge/rapier3d-compat";
|
|
2
|
+
import { GroupProps } from "@react-three/fiber";
|
|
3
|
+
import { RapierRigidBody, RigidBodyProps } from "@react-three/rapier";
|
|
4
|
+
import { ReactNode, RefObject } from "react";
|
|
5
|
+
import * as THREE from "three";
|
|
6
|
+
import { cameraRayType } from "../camera/type";
|
|
7
|
+
import { keyControlType, urlsType } from "../world/context/type";
|
|
8
|
+
import { airplaneType, characterType, vehicleType } from "./context/type";
|
|
9
|
+
import { callbackType } from "./initialize/callback/type";
|
|
10
|
+
export type optionsType = {
|
|
11
|
+
debug: boolean;
|
|
12
|
+
mode?: "normal" | "vehicle" | "airplane";
|
|
13
|
+
controllerType: "none" | "gameboy" | "joystick" | "keyboard";
|
|
14
|
+
cameraCollisionType: "transparent" | "closeUp";
|
|
15
|
+
camera: {
|
|
16
|
+
type: "perspective" | "orthographic";
|
|
17
|
+
control: "orbit" | "normal";
|
|
18
|
+
};
|
|
19
|
+
minimap: boolean;
|
|
20
|
+
minimapRatio: number;
|
|
21
|
+
};
|
|
22
|
+
export type partialOptionsType = Partial<optionsType>;
|
|
23
|
+
export type jumpInnerType = {
|
|
24
|
+
velocity: THREE.Vector3;
|
|
25
|
+
direction: THREE.Vector3;
|
|
26
|
+
};
|
|
27
|
+
export type jumpConstType = {
|
|
28
|
+
speed: number;
|
|
29
|
+
gravity: number;
|
|
30
|
+
};
|
|
31
|
+
export type jumpPropType = jumpInnerType & jumpConstType;
|
|
32
|
+
export type rayType = {
|
|
33
|
+
origin: THREE.Vector3;
|
|
34
|
+
hit: RayColliderToi | null;
|
|
35
|
+
rayCast: Ray | null;
|
|
36
|
+
dir: THREE.Vector3;
|
|
37
|
+
offset: THREE.Vector3;
|
|
38
|
+
length: number;
|
|
39
|
+
current?: THREE.Vector3;
|
|
40
|
+
angle?: number;
|
|
41
|
+
parent?: RapierRigidBody | null | undefined;
|
|
42
|
+
};
|
|
43
|
+
export type slopeRayType = Omit<rayType, "parent">;
|
|
44
|
+
export type groundRayType = Omit<rayType, "current" | "angle">;
|
|
45
|
+
export type controllerInnerType = {
|
|
46
|
+
name?: string;
|
|
47
|
+
groundRay: groundRayType;
|
|
48
|
+
cameraRay: cameraRayType;
|
|
49
|
+
keyControl: keyControlType;
|
|
50
|
+
} & controllerOtherPropType & refsType & callbackType;
|
|
51
|
+
export type animationTagType = {
|
|
52
|
+
idle: string;
|
|
53
|
+
walk: string;
|
|
54
|
+
run: string;
|
|
55
|
+
jump: string;
|
|
56
|
+
jumpIdle: string;
|
|
57
|
+
jumpLand: string;
|
|
58
|
+
fall: string;
|
|
59
|
+
ride: string;
|
|
60
|
+
land: string;
|
|
61
|
+
sit: string;
|
|
62
|
+
};
|
|
63
|
+
export type actionsType = animationTagType & {
|
|
64
|
+
[key: string]: string;
|
|
65
|
+
};
|
|
66
|
+
export type refsType = {
|
|
67
|
+
colliderRef: RefObject<Collider>;
|
|
68
|
+
rigidBodyRef: RefObject<RapierRigidBody>;
|
|
69
|
+
outerGroupRef: RefObject<THREE.Group>;
|
|
70
|
+
innerGroupRef: RefObject<THREE.Group>;
|
|
71
|
+
characterInnerRef: RefObject<THREE.Group>;
|
|
72
|
+
};
|
|
73
|
+
export type gaesupControllerContextPropType = {
|
|
74
|
+
airplane: airplaneType;
|
|
75
|
+
vehicle: vehicleType;
|
|
76
|
+
character: characterType;
|
|
77
|
+
urls: urlsType;
|
|
78
|
+
};
|
|
79
|
+
export interface controllerOtherPropType extends RigidBodyProps {
|
|
80
|
+
children?: ReactNode;
|
|
81
|
+
groupProps?: GroupProps;
|
|
82
|
+
rigidBodyProps?: RigidBodyProps;
|
|
83
|
+
debug?: boolean;
|
|
84
|
+
}
|
|
85
|
+
export type controllerType = controllerOtherPropType & Partial<gaesupControllerContextPropType> & callbackType;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare function GaeSupProps({ type, text, position, children, }: {
|
|
3
|
+
type?: "normal" | "ground";
|
|
4
|
+
text?: string;
|
|
5
|
+
position?: [number, number, number];
|
|
6
|
+
children: React.ReactNode;
|
|
7
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,46 @@
|
|
|
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 { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
import { vec3 } from "@react-three/rapier";
|
|
14
|
+
import { Suspense, useContext, useEffect, useMemo, useRef } from "react";
|
|
15
|
+
import * as THREE from "three";
|
|
16
|
+
import { GaesupWorldContext, GaesupWorldDispatchContext, } from "../world/context/index.js";
|
|
17
|
+
export function GaeSupProps(_a) {
|
|
18
|
+
var _b = _a.type, type = _b === void 0 ? "normal" : _b, text = _a.text, position = _a.position, children = _a.children;
|
|
19
|
+
var groupRef = useRef(null);
|
|
20
|
+
var minimap = useContext(GaesupWorldContext).minimap;
|
|
21
|
+
var dispatch = useContext(GaesupWorldDispatchContext);
|
|
22
|
+
var groupComponent = useMemo(function () {
|
|
23
|
+
return (_jsx("group", { ref: groupRef, position: position, children: children }));
|
|
24
|
+
}, []);
|
|
25
|
+
useEffect(function () {
|
|
26
|
+
if (groupRef.current) {
|
|
27
|
+
var box = new THREE.Box3().setFromObject(groupRef.current);
|
|
28
|
+
var size = vec3(box.getSize(new THREE.Vector3())).clone();
|
|
29
|
+
var center = vec3(box.getCenter(new THREE.Vector3())).clone();
|
|
30
|
+
var obj = {
|
|
31
|
+
type: type ? type : "normal",
|
|
32
|
+
text: text,
|
|
33
|
+
size: size,
|
|
34
|
+
center: center,
|
|
35
|
+
};
|
|
36
|
+
minimap.props[text] = obj;
|
|
37
|
+
dispatch({
|
|
38
|
+
type: "update",
|
|
39
|
+
payload: {
|
|
40
|
+
minimap: __assign({}, minimap),
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}, []);
|
|
45
|
+
return _jsx(Suspense, { fallback: null, children: groupComponent });
|
|
46
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { animationAtomType } from "../../world/context/type";
|
|
2
|
+
export declare function useGaesupAnimation({ type, }: {
|
|
3
|
+
type: "character" | "vehicle" | "airplane";
|
|
4
|
+
}): {
|
|
5
|
+
subscribe: ({ tag, condition, action, animationName, key, }: animationAtomType) => void;
|
|
6
|
+
subscribeAll: (props: animationAtomType[]) => void;
|
|
7
|
+
store: {};
|
|
8
|
+
unsubscribe: (tag: string) => void;
|
|
9
|
+
notify: () => string;
|
|
10
|
+
};
|
|
@@ -0,0 +1,95 @@
|
|
|
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(_a) {
|
|
15
|
+
var type = _a.type;
|
|
16
|
+
var animationState = useContext(GaesupWorldContext).animationState;
|
|
17
|
+
var dispatch = useContext(GaesupWorldDispatchContext);
|
|
18
|
+
var getAnimationTag = function (tag) {
|
|
19
|
+
var animation = animationState[type].store[tag];
|
|
20
|
+
if (!animation)
|
|
21
|
+
return { name: animationState[type].default, isValid: false };
|
|
22
|
+
if (animation.condition()) {
|
|
23
|
+
return { name: animation.animationName, isValid: true };
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
return { name: animationState[type].default, isValid: false };
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
var notify = function () {
|
|
30
|
+
var tag = animationState[type].default;
|
|
31
|
+
for (var _i = 0, _a = Object.keys(animationState[type].store); _i < _a.length; _i++) {
|
|
32
|
+
var key = _a[_i];
|
|
33
|
+
var checked = getAnimationTag(key);
|
|
34
|
+
if (checked.isValid) {
|
|
35
|
+
tag = checked.name;
|
|
36
|
+
break;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
animationState[type].current = tag;
|
|
40
|
+
dispatch({
|
|
41
|
+
type: "update",
|
|
42
|
+
payload: {
|
|
43
|
+
animationState: __assign({}, animationState),
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
return tag;
|
|
47
|
+
};
|
|
48
|
+
var unsubscribe = function (tag) {
|
|
49
|
+
delete animationState[type].store[tag];
|
|
50
|
+
dispatch({
|
|
51
|
+
type: "update",
|
|
52
|
+
payload: {
|
|
53
|
+
animationState: __assign({}, animationState),
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
var subscribe = function (_a) {
|
|
58
|
+
var tag = _a.tag, condition = _a.condition, action = _a.action, animationName = _a.animationName, key = _a.key;
|
|
59
|
+
animationState[type].store[tag] = {
|
|
60
|
+
condition: condition,
|
|
61
|
+
action: action || (function () { }),
|
|
62
|
+
animationName: animationName || tag,
|
|
63
|
+
key: key || tag,
|
|
64
|
+
};
|
|
65
|
+
dispatch({
|
|
66
|
+
type: "update",
|
|
67
|
+
payload: {
|
|
68
|
+
animationState: __assign({}, animationState),
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
};
|
|
72
|
+
var subscribeAll = function (props) {
|
|
73
|
+
props.forEach(function (item) {
|
|
74
|
+
animationState[type].store[item.tag] = {
|
|
75
|
+
condition: item.condition,
|
|
76
|
+
action: item.action,
|
|
77
|
+
animationName: item.animationName,
|
|
78
|
+
key: item.key,
|
|
79
|
+
};
|
|
80
|
+
});
|
|
81
|
+
dispatch({
|
|
82
|
+
type: "update",
|
|
83
|
+
payload: {
|
|
84
|
+
animationState: __assign({}, animationState),
|
|
85
|
+
},
|
|
86
|
+
});
|
|
87
|
+
};
|
|
88
|
+
return {
|
|
89
|
+
subscribe: subscribe,
|
|
90
|
+
subscribeAll: subscribeAll,
|
|
91
|
+
store: animationState[type].store,
|
|
92
|
+
unsubscribe: unsubscribe,
|
|
93
|
+
notify: notify,
|
|
94
|
+
};
|
|
95
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { activeStateType, modeType, urlsType } from "../../world/context/type";
|
|
3
|
+
export declare function useGaesupController(): gaesupPassivePropsType;
|
|
4
|
+
export type gaesupPassivePropsType = {
|
|
5
|
+
state: activeStateType;
|
|
6
|
+
mode: modeType;
|
|
7
|
+
urls: urlsType;
|
|
8
|
+
currentAnimation: string;
|
|
9
|
+
children?: React.ReactNode;
|
|
10
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// "Please use this only as a subcomponent of GaesupWorld."
|
|
2
|
+
import { useContext } from "react";
|
|
3
|
+
import { GaesupWorldContext } from "../../world/context";
|
|
4
|
+
export function useGaesupController() {
|
|
5
|
+
var worldContext = useContext(GaesupWorldContext);
|
|
6
|
+
return {
|
|
7
|
+
state: worldContext.activeState,
|
|
8
|
+
mode: worldContext.mode,
|
|
9
|
+
urls: worldContext.urls,
|
|
10
|
+
currentAnimation: worldContext.mode.type
|
|
11
|
+
? worldContext.animationState[worldContext.mode.type].current
|
|
12
|
+
: "idle",
|
|
13
|
+
};
|
|
14
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import * as THREE from "three";
|
|
2
|
+
import { GLTFResult } from "../../component/type";
|
|
3
|
+
import { urlsType } from "../../world/context/type";
|
|
4
|
+
export type gltfAndSizeType = {
|
|
5
|
+
size: THREE.Vector3;
|
|
6
|
+
setSize: (size: THREE.Vector3, keyName?: string) => void;
|
|
7
|
+
getSize: () => THREE.Vector3;
|
|
8
|
+
};
|
|
9
|
+
export type useGltfAndSizeType = {
|
|
10
|
+
url: string;
|
|
11
|
+
};
|
|
12
|
+
export declare const useGltfAndSize: ({ url }: useGltfAndSizeType) => {
|
|
13
|
+
gltf: GLTFResult;
|
|
14
|
+
size: THREE.Vector3;
|
|
15
|
+
setSize: (size?: THREE.Vector3, keyName?: string) => THREE.Vector3;
|
|
16
|
+
getSize: (keyName?: string) => THREE.Vector3;
|
|
17
|
+
};
|
|
18
|
+
export declare const useGaesupGltf: () => {
|
|
19
|
+
getSizesByUrls: (urls?: urlsType) => {
|
|
20
|
+
characterUrl?: THREE.Vector3;
|
|
21
|
+
vehicleUrl?: THREE.Vector3;
|
|
22
|
+
airplaneUrl?: THREE.Vector3;
|
|
23
|
+
wheelUrl?: THREE.Vector3;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
@@ -0,0 +1,73 @@
|
|
|
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 { useGLTF } from "@react-three/drei";
|
|
13
|
+
import { useContext } from "react";
|
|
14
|
+
import * as THREE from "three";
|
|
15
|
+
import { GaesupWorldContext, GaesupWorldDispatchContext, } from "../../world/context";
|
|
16
|
+
export var useGltfAndSize = function (_a) {
|
|
17
|
+
var url = _a.url;
|
|
18
|
+
var sizes = useContext(GaesupWorldContext).sizes;
|
|
19
|
+
var dispatch = useContext(GaesupWorldDispatchContext);
|
|
20
|
+
var gltf = useGLTF(url);
|
|
21
|
+
var scene = gltf.scene;
|
|
22
|
+
var makeGltfSize = function () {
|
|
23
|
+
return new THREE.Box3().setFromObject(scene).getSize(new THREE.Vector3());
|
|
24
|
+
};
|
|
25
|
+
// getter
|
|
26
|
+
var getSize = function (keyName) {
|
|
27
|
+
var key = keyName || url;
|
|
28
|
+
if (key in sizes) {
|
|
29
|
+
return sizes[key];
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
// setter
|
|
36
|
+
var setSize = function (size, keyName) {
|
|
37
|
+
var key = keyName || url;
|
|
38
|
+
if (!(key in sizes)) {
|
|
39
|
+
sizes[key] = size || makeGltfSize();
|
|
40
|
+
dispatch({
|
|
41
|
+
type: "update",
|
|
42
|
+
payload: {
|
|
43
|
+
sizes: __assign({}, sizes),
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
return sizes[key];
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
return sizes[key];
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
return { gltf: gltf, size: setSize(), setSize: setSize, getSize: getSize };
|
|
53
|
+
};
|
|
54
|
+
export var useGaesupGltf = function () {
|
|
55
|
+
var sizes = useContext(GaesupWorldContext).sizes;
|
|
56
|
+
// get size by url
|
|
57
|
+
var getSizesByUrls = function (urls) {
|
|
58
|
+
var matchedSizes = {};
|
|
59
|
+
if (!urls)
|
|
60
|
+
return matchedSizes;
|
|
61
|
+
Object.keys(urls).forEach(function (key) {
|
|
62
|
+
var url = urls[key];
|
|
63
|
+
if (url in sizes) {
|
|
64
|
+
matchedSizes[key] = sizes[url];
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
matchedSizes[key] = null;
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
return matchedSizes;
|
|
71
|
+
};
|
|
72
|
+
return { getSizesByUrls: getSizesByUrls };
|
|
73
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { joyStickBallType, joyStickOriginType } from "../../tools/joyStick/type";
|
|
2
|
+
export declare const joyStickBallDefault: {
|
|
3
|
+
top: string;
|
|
4
|
+
left: string;
|
|
5
|
+
};
|
|
6
|
+
export declare const joyStickOriginDefault: {
|
|
7
|
+
x: number;
|
|
8
|
+
y: number;
|
|
9
|
+
angle: number;
|
|
10
|
+
currentRadius: number;
|
|
11
|
+
originRadius: number;
|
|
12
|
+
isIn: boolean;
|
|
13
|
+
isOn: boolean;
|
|
14
|
+
isUp: boolean;
|
|
15
|
+
isCenter: boolean;
|
|
16
|
+
};
|
|
17
|
+
export declare const joyStickInnerDefault: {
|
|
18
|
+
joyStickBall: {
|
|
19
|
+
top: string;
|
|
20
|
+
left: string;
|
|
21
|
+
};
|
|
22
|
+
joyStickOrigin: {
|
|
23
|
+
x: number;
|
|
24
|
+
y: number;
|
|
25
|
+
angle: number;
|
|
26
|
+
currentRadius: number;
|
|
27
|
+
originRadius: number;
|
|
28
|
+
isIn: boolean;
|
|
29
|
+
isOn: boolean;
|
|
30
|
+
isUp: boolean;
|
|
31
|
+
isCenter: boolean;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
export default function useJoyStick(): {
|
|
35
|
+
joyStickOrigin: joyStickOriginType;
|
|
36
|
+
joyStickBall: joyStickBallType;
|
|
37
|
+
setBall: (ball: joyStickBallType) => void;
|
|
38
|
+
setOrigin: (origin: joyStickOriginType) => void;
|
|
39
|
+
};
|
|
@@ -0,0 +1,61 @@
|
|
|
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 var joyStickBallDefault = {
|
|
15
|
+
top: "50%",
|
|
16
|
+
left: "50%",
|
|
17
|
+
};
|
|
18
|
+
export var joyStickOriginDefault = {
|
|
19
|
+
x: 0,
|
|
20
|
+
y: 0,
|
|
21
|
+
angle: Math.PI / 2,
|
|
22
|
+
currentRadius: 0,
|
|
23
|
+
originRadius: 0,
|
|
24
|
+
isIn: true,
|
|
25
|
+
isOn: false,
|
|
26
|
+
isUp: true,
|
|
27
|
+
isCenter: true,
|
|
28
|
+
};
|
|
29
|
+
export var joyStickInnerDefault = {
|
|
30
|
+
joyStickBall: joyStickBallDefault,
|
|
31
|
+
joyStickOrigin: joyStickOriginDefault,
|
|
32
|
+
};
|
|
33
|
+
export default function useJoyStick() {
|
|
34
|
+
var joystick = useContext(GaesupWorldContext).joystick;
|
|
35
|
+
var dispatch = useContext(GaesupWorldDispatchContext);
|
|
36
|
+
var joyStickBall = joystick.joyStickBall, joyStickOrigin = joystick.joyStickOrigin;
|
|
37
|
+
var setBall = function (ball) {
|
|
38
|
+
joystick.joyStickBall = Object.assign(joyStickBall, ball);
|
|
39
|
+
dispatch({
|
|
40
|
+
type: "update",
|
|
41
|
+
payload: {
|
|
42
|
+
joystick: __assign(__assign({}, joystick), { joyStickBall: __assign({}, joystick.joyStickBall) }),
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
var setOrigin = function (origin) {
|
|
47
|
+
joystick.joyStickOrigin = Object.assign(joyStickOrigin, origin);
|
|
48
|
+
dispatch({
|
|
49
|
+
type: "update",
|
|
50
|
+
payload: {
|
|
51
|
+
joystick: __assign(__assign({}, joystick), { joyStickOrigin: __assign({}, joystick.joyStickOrigin) }),
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
return {
|
|
56
|
+
joyStickOrigin: joyStickOrigin,
|
|
57
|
+
joyStickBall: joyStickBall,
|
|
58
|
+
setBall: setBall,
|
|
59
|
+
setOrigin: setOrigin,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
@@ -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
|
+
import { useContext } from "react";
|
|
13
|
+
import { GaesupWorldContext, GaesupWorldDispatchContext, } from "../../world/context";
|
|
14
|
+
export function usePushKey() {
|
|
15
|
+
var control = useContext(GaesupWorldContext).control;
|
|
16
|
+
var dispatch = useContext(GaesupWorldDispatchContext);
|
|
17
|
+
var pushKey = function (key, value) {
|
|
18
|
+
control[key] = value;
|
|
19
|
+
dispatch({
|
|
20
|
+
type: "update",
|
|
21
|
+
payload: {
|
|
22
|
+
control: __assign({}, control),
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
return {
|
|
27
|
+
pushKey: pushKey,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
@@ -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
|
+
};
|