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.
Files changed (216) hide show
  1. package/dist/gaesup/animation/actions.d.ts +44 -0
  2. package/dist/gaesup/animation/actions.js +103 -0
  3. package/dist/gaesup/camera/control/normal.d.ts +4 -0
  4. package/dist/gaesup/camera/control/normal.js +18 -0
  5. package/dist/gaesup/camera/control/orbit.d.ts +4 -0
  6. package/dist/gaesup/camera/control/orbit.js +22 -0
  7. package/dist/gaesup/camera/detector/index.d.ts +2 -0
  8. package/dist/gaesup/camera/detector/index.js +25 -0
  9. package/dist/gaesup/camera/index.d.ts +8 -0
  10. package/dist/gaesup/camera/index.js +139 -0
  11. package/dist/gaesup/camera/type.d.ts +13 -0
  12. package/dist/gaesup/camera/type.js +1 -0
  13. package/dist/gaesup/component/active/airplane/index.d.ts +11 -0
  14. package/dist/gaesup/component/active/airplane/index.js +6 -0
  15. package/dist/gaesup/component/active/character/index.d.ts +7 -0
  16. package/dist/gaesup/component/active/character/index.js +34 -0
  17. package/dist/gaesup/component/active/vehicle/index.d.ts +12 -0
  18. package/dist/gaesup/component/active/vehicle/index.js +31 -0
  19. package/dist/gaesup/component/index.d.ts +7 -0
  20. package/dist/gaesup/component/index.js +19 -0
  21. package/dist/gaesup/component/inner/airplane/index.d.ts +2 -0
  22. package/dist/gaesup/component/inner/airplane/index.js +16 -0
  23. package/dist/gaesup/component/inner/character/index.d.ts +25 -0
  24. package/dist/gaesup/component/inner/character/index.js +28 -0
  25. package/dist/gaesup/component/inner/common/InnerGroupRef.d.ts +10 -0
  26. package/dist/gaesup/component/inner/common/InnerGroupRef.js +29 -0
  27. package/dist/gaesup/component/inner/common/OuterGroupRef.d.ts +4 -0
  28. package/dist/gaesup/component/inner/common/OuterGroupRef.js +6 -0
  29. package/dist/gaesup/component/inner/common/RigidbodyRef.d.ts +12 -0
  30. package/dist/gaesup/component/inner/common/RigidbodyRef.js +7 -0
  31. package/dist/gaesup/component/inner/common/setGroundRay.d.ts +9 -0
  32. package/dist/gaesup/component/inner/common/setGroundRay.js +14 -0
  33. package/dist/gaesup/component/inner/common/type.d.ts +20 -0
  34. package/dist/gaesup/component/inner/common/type.js +1 -0
  35. package/dist/gaesup/component/inner/rider/index.d.ts +11 -0
  36. package/dist/gaesup/component/inner/rider/index.js +31 -0
  37. package/dist/gaesup/component/inner/vehicle/collider.d.ts +10 -0
  38. package/dist/gaesup/component/inner/vehicle/collider.js +19 -0
  39. package/dist/gaesup/component/inner/vehicle/index.d.ts +2 -0
  40. package/dist/gaesup/component/inner/vehicle/index.js +17 -0
  41. package/dist/gaesup/component/inner/vehicle/wheels.d.ts +7 -0
  42. package/dist/gaesup/component/inner/vehicle/wheels.js +64 -0
  43. package/dist/gaesup/component/passive/airplane/index.d.ts +13 -0
  44. package/dist/gaesup/component/passive/airplane/index.js +40 -0
  45. package/dist/gaesup/component/passive/character/index.d.ts +10 -0
  46. package/dist/gaesup/component/passive/character/index.js +46 -0
  47. package/dist/gaesup/component/passive/type.d.ts +20 -0
  48. package/dist/gaesup/component/passive/type.js +1 -0
  49. package/dist/gaesup/component/passive/vehicle/index.d.ts +13 -0
  50. package/dist/gaesup/component/passive/vehicle/index.js +17 -0
  51. package/dist/gaesup/component/type.d.ts +17 -0
  52. package/dist/gaesup/component/type.js +1 -0
  53. package/dist/gaesup/controller/context/index.d.ts +49 -0
  54. package/dist/gaesup/controller/context/index.js +59 -0
  55. package/dist/gaesup/controller/context/reducer.d.ts +12 -0
  56. package/dist/gaesup/controller/context/reducer.js +21 -0
  57. package/dist/gaesup/controller/context/type.d.ts +38 -0
  58. package/dist/gaesup/controller/context/type.js +1 -0
  59. package/dist/gaesup/controller/debug/airplane.d.ts +71 -0
  60. package/dist/gaesup/controller/debug/airplane.js +71 -0
  61. package/dist/gaesup/controller/debug/character.d.ts +27 -0
  62. package/dist/gaesup/controller/debug/character.js +27 -0
  63. package/dist/gaesup/controller/debug/index.d.ts +6 -0
  64. package/dist/gaesup/controller/debug/index.js +49 -0
  65. package/dist/gaesup/controller/debug/vehicle.d.ts +27 -0
  66. package/dist/gaesup/controller/debug/vehicle.js +27 -0
  67. package/dist/gaesup/controller/index.d.ts +3 -0
  68. package/dist/gaesup/controller/index.js +74 -0
  69. package/dist/gaesup/controller/initialize/callback/index.d.ts +2 -0
  70. package/dist/gaesup/controller/initialize/callback/index.js +62 -0
  71. package/dist/gaesup/controller/initialize/callback/type.d.ts +27 -0
  72. package/dist/gaesup/controller/initialize/callback/type.js +1 -0
  73. package/dist/gaesup/controller/initialize/index.d.ts +10 -0
  74. package/dist/gaesup/controller/initialize/index.js +75 -0
  75. package/dist/gaesup/controller/type.d.ts +85 -0
  76. package/dist/gaesup/controller/type.js +1 -0
  77. package/dist/gaesup/gaesupProps/index.d.ts +7 -0
  78. package/dist/gaesup/gaesupProps/index.js +46 -0
  79. package/dist/gaesup/hooks/useGaesupAnimation/index.d.ts +10 -0
  80. package/dist/gaesup/hooks/useGaesupAnimation/index.js +95 -0
  81. package/dist/gaesup/hooks/useGaesupController/index.d.ts +10 -0
  82. package/dist/gaesup/hooks/useGaesupController/index.js +14 -0
  83. package/dist/gaesup/hooks/useGaesupGltf/index.d.ts +25 -0
  84. package/dist/gaesup/hooks/useGaesupGltf/index.js +73 -0
  85. package/dist/gaesup/hooks/useJoyStick/index.d.ts +39 -0
  86. package/dist/gaesup/hooks/useJoyStick/index.js +61 -0
  87. package/dist/gaesup/hooks/usePushKey/index.d.ts +3 -0
  88. package/dist/gaesup/hooks/usePushKey/index.js +29 -0
  89. package/dist/gaesup/hooks/useRideable/index.d.ts +28 -0
  90. package/dist/gaesup/hooks/useRideable/index.js +199 -0
  91. package/dist/gaesup/hooks/useTeleport/index.d.ts +3 -0
  92. package/dist/gaesup/hooks/useTeleport/index.js +12 -0
  93. package/dist/gaesup/physics/airplane/damping.d.ts +2 -0
  94. package/dist/gaesup/physics/airplane/damping.js +5 -0
  95. package/dist/gaesup/physics/airplane/direction.d.ts +2 -0
  96. package/dist/gaesup/physics/airplane/direction.js +65 -0
  97. package/dist/gaesup/physics/airplane/gravity.d.ts +14 -0
  98. package/dist/gaesup/physics/airplane/gravity.js +18 -0
  99. package/dist/gaesup/physics/airplane/impulse.d.ts +16 -0
  100. package/dist/gaesup/physics/airplane/impulse.js +31 -0
  101. package/dist/gaesup/physics/airplane/index.d.ts +2 -0
  102. package/dist/gaesup/physics/airplane/index.js +14 -0
  103. package/dist/gaesup/physics/airplane/innerCalc.d.ts +2 -0
  104. package/dist/gaesup/physics/airplane/innerCalc.js +27 -0
  105. package/dist/gaesup/physics/airplane/landing.d.ts +2 -0
  106. package/dist/gaesup/physics/airplane/landing.js +29 -0
  107. package/dist/gaesup/physics/character/direction.d.ts +23 -0
  108. package/dist/gaesup/physics/character/direction.js +55 -0
  109. package/dist/gaesup/physics/character/impulse.d.ts +2 -0
  110. package/dist/gaesup/physics/character/impulse.js +43 -0
  111. package/dist/gaesup/physics/character/index.d.ts +2 -0
  112. package/dist/gaesup/physics/character/index.js +8 -0
  113. package/dist/gaesup/physics/character/innerCalc.d.ts +2 -0
  114. package/dist/gaesup/physics/character/innerCalc.js +31 -0
  115. package/dist/gaesup/physics/check/ground.d.ts +2 -0
  116. package/dist/gaesup/physics/check/ground.js +15 -0
  117. package/dist/gaesup/physics/check/index.d.ts +2 -0
  118. package/dist/gaesup/physics/check/index.js +12 -0
  119. package/dist/gaesup/physics/check/moving.d.ts +2 -0
  120. package/dist/gaesup/physics/check/moving.js +16 -0
  121. package/dist/gaesup/physics/check/push.d.ts +2 -0
  122. package/dist/gaesup/physics/check/push.js +6 -0
  123. package/dist/gaesup/physics/check/riding.d.ts +2 -0
  124. package/dist/gaesup/physics/check/riding.js +7 -0
  125. package/dist/gaesup/physics/check/rotate.d.ts +2 -0
  126. package/dist/gaesup/physics/check/rotate.js +8 -0
  127. package/dist/gaesup/physics/index.d.ts +2 -0
  128. package/dist/gaesup/physics/index.js +58 -0
  129. package/dist/gaesup/physics/type.d.ts +36 -0
  130. package/dist/gaesup/physics/type.js +1 -0
  131. package/dist/gaesup/physics/vehicle/damping.d.ts +2 -0
  132. package/dist/gaesup/physics/vehicle/damping.js +6 -0
  133. package/dist/gaesup/physics/vehicle/direction.d.ts +4 -0
  134. package/dist/gaesup/physics/vehicle/direction.js +30 -0
  135. package/dist/gaesup/physics/vehicle/impulse.d.ts +16 -0
  136. package/dist/gaesup/physics/vehicle/impulse.js +40 -0
  137. package/dist/gaesup/physics/vehicle/index.d.ts +2 -0
  138. package/dist/gaesup/physics/vehicle/index.js +12 -0
  139. package/dist/gaesup/physics/vehicle/innerCalc.d.ts +2 -0
  140. package/dist/gaesup/physics/vehicle/innerCalc.js +24 -0
  141. package/dist/gaesup/physics/vehicle/landing.d.ts +2 -0
  142. package/dist/gaesup/physics/vehicle/landing.js +29 -0
  143. package/dist/gaesup/tools/gameBoy/GameBoyButton.d.ts +9 -0
  144. package/dist/gaesup/tools/gameBoy/GameBoyButton.js +16 -0
  145. package/dist/gaesup/tools/gameBoy/index.d.ts +8 -0
  146. package/dist/gaesup/tools/gameBoy/index.js +22 -0
  147. package/dist/gaesup/tools/gameBoy/type.d.ts +4 -0
  148. package/dist/gaesup/tools/gameBoy/type.js +1 -0
  149. package/dist/gaesup/tools/gamePad/GamePadButton.d.ts +8 -0
  150. package/dist/gaesup/tools/gamePad/GamePadButton.js +21 -0
  151. package/dist/gaesup/tools/gamePad/index.d.ts +6 -0
  152. package/dist/gaesup/tools/gamePad/index.js +32 -0
  153. package/dist/gaesup/tools/gamePad/type.d.ts +6 -0
  154. package/dist/gaesup/tools/gamePad/type.js +1 -0
  155. package/dist/gaesup/tools/joyStick/index.d.ts +6 -0
  156. package/dist/gaesup/tools/joyStick/index.js +169 -0
  157. package/dist/gaesup/tools/joyStick/type.d.ts +19 -0
  158. package/dist/gaesup/tools/joyStick/type.js +1 -0
  159. package/dist/gaesup/tools/jumpPortal/index.d.ts +16 -0
  160. package/dist/gaesup/tools/jumpPortal/index.js +18 -0
  161. package/dist/gaesup/tools/keyBoardToolTip/constant.d.ts +402 -0
  162. package/dist/gaesup/tools/keyBoardToolTip/constant.js +122 -0
  163. package/dist/gaesup/tools/keyBoardToolTip/default.d.ts +10 -0
  164. package/dist/gaesup/tools/keyBoardToolTip/default.js +12 -0
  165. package/dist/gaesup/tools/keyBoardToolTip/index.d.ts +3 -0
  166. package/dist/gaesup/tools/keyBoardToolTip/index.js +70 -0
  167. package/dist/gaesup/tools/keyBoardToolTip/type.d.ts +37 -0
  168. package/dist/gaesup/tools/keyBoardToolTip/type.js +1 -0
  169. package/dist/gaesup/tools/miniMap/default.d.ts +9 -0
  170. package/dist/gaesup/tools/miniMap/default.js +9 -0
  171. package/dist/gaesup/tools/miniMap/index.d.ts +3 -0
  172. package/dist/gaesup/tools/miniMap/index.js +72 -0
  173. package/dist/gaesup/tools/miniMap/type.d.ts +25 -0
  174. package/dist/gaesup/tools/miniMap/type.js +1 -0
  175. package/dist/gaesup/tools/rideable/index.d.ts +3 -0
  176. package/dist/gaesup/tools/rideable/index.js +79 -0
  177. package/dist/gaesup/tools/type.d.ts +2 -0
  178. package/dist/gaesup/tools/type.js +1 -0
  179. package/dist/gaesup/tools/zoomButton/index.d.ts +18 -0
  180. package/dist/gaesup/tools/zoomButton/index.js +146 -0
  181. package/dist/gaesup/utils/context.d.ts +2 -0
  182. package/dist/gaesup/utils/context.js +3 -0
  183. package/dist/gaesup/utils/debug.d.ts +29 -0
  184. package/dist/gaesup/utils/debug.js +36 -0
  185. package/dist/gaesup/utils/index.d.ts +3 -0
  186. package/dist/gaesup/utils/index.js +3 -0
  187. package/dist/gaesup/utils/ray.d.ts +7 -0
  188. package/dist/gaesup/utils/ray.js +6 -0
  189. package/dist/gaesup/utils/ref.d.ts +2 -0
  190. package/dist/gaesup/utils/ref.js +16 -0
  191. package/dist/gaesup/utils/type.d.ts +5 -0
  192. package/dist/gaesup/utils/type.js +1 -0
  193. package/dist/gaesup/utils/vector.d.ts +10 -0
  194. package/dist/gaesup/utils/vector.js +33 -0
  195. package/dist/gaesup/world/context/index.d.ts +6 -0
  196. package/dist/gaesup/world/context/index.js +117 -0
  197. package/dist/gaesup/world/context/reducer.d.ts +29 -0
  198. package/dist/gaesup/world/context/reducer.js +21 -0
  199. package/dist/gaesup/world/context/type.d.ts +169 -0
  200. package/dist/gaesup/world/context/type.js +1 -0
  201. package/dist/gaesup/world/debug/cameraOption.d.ts +47 -0
  202. package/dist/gaesup/world/debug/cameraOption.js +47 -0
  203. package/dist/gaesup/world/debug/index.d.ts +6 -0
  204. package/dist/gaesup/world/debug/index.js +32 -0
  205. package/dist/gaesup/world/debug/mode.d.ts +10 -0
  206. package/dist/gaesup/world/debug/mode.js +10 -0
  207. package/dist/gaesup/world/index.d.ts +3 -0
  208. package/dist/gaesup/world/index.js +9 -0
  209. package/dist/gaesup/world/initalize/index.d.ts +35 -0
  210. package/dist/gaesup/world/initalize/index.js +62 -0
  211. package/dist/gaesup/world/type.d.ts +19 -0
  212. package/dist/gaesup/world/type.js +1 -0
  213. package/dist/index.d.ts +23 -0
  214. package/index.ts +29 -0
  215. package/package.json +2 -5
  216. package/yarn-error.log +12152 -0
@@ -0,0 +1,29 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useGraph } from "@react-three/fiber";
3
+ import { Suspense, forwardRef, useMemo } from "react";
4
+ import * as THREE from "three";
5
+ import { SkeletonUtils } from "three-stdlib";
6
+ import { useAnimations, useGLTF } from "@react-three/drei";
7
+ import playActions from "../../../animation/actions";
8
+ export var InnerGroupRef = forwardRef(function (_a, ref) {
9
+ var children = _a.children, type = _a.type, currentAnimation = _a.currentAnimation, url = _a.url, rotation = _a.rotation;
10
+ var _b = useGLTF(url), scene = _b.scene, animations = _b.animations;
11
+ var animationResult = useAnimations(animations);
12
+ var animationRef = playActions({
13
+ type: type,
14
+ animationResult: animationResult,
15
+ currentAnimation: currentAnimation,
16
+ }).animationRef;
17
+ var clone = useMemo(function () { return SkeletonUtils.clone(scene); }, [scene]);
18
+ var nodes = useGraph(clone).nodes;
19
+ var objectNode = Object.values(nodes).find(function (node) { return node.type === "Object3D"; });
20
+ return (_jsx(Suspense, { fallback: null, children: _jsxs("group", { receiveShadow: true, castShadow: true, ref: ref, rotation: rotation, userData: { intangible: true }, children: [children, objectNode && animationRef && (_jsx("primitive", { object: objectNode, visible: false, receiveShadow: true, castShadow: true, ref: animationRef })), Object.keys(nodes).map(function (name, key) {
21
+ var node = nodes[name];
22
+ if (node instanceof THREE.SkinnedMesh) {
23
+ return (_jsx("skinnedMesh", { castShadow: true, receiveShadow: true, material: node.material, geometry: node.geometry, skeleton: node.skeleton }, key));
24
+ }
25
+ else if (node instanceof THREE.Mesh) {
26
+ return (_jsx("mesh", { castShadow: true, receiveShadow: true, material: node.material, geometry: node.geometry }, key));
27
+ }
28
+ })] }) }));
29
+ });
@@ -0,0 +1,4 @@
1
+ import { ReactNode } from "react";
2
+ export declare const OuterGroupRef: import("react").ForwardRefExoticComponent<{
3
+ children: ReactNode;
4
+ } & import("react").RefAttributes<import("three").Group<import("three").Object3DEventMap>>>;
@@ -0,0 +1,6 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { forwardRef } from "react";
3
+ export var OuterGroupRef = forwardRef(function (_a, ref) {
4
+ var children = _a.children;
5
+ return (_jsx("group", { ref: ref, userData: { intangible: true }, children: children }));
6
+ });
@@ -0,0 +1,12 @@
1
+ import { CollisionEnterPayload, RapierRigidBody } from "@react-three/rapier";
2
+ import { ReactNode } from "react";
3
+ export declare const RigidBodyRef: import("react").ForwardRefExoticComponent<{
4
+ children: ReactNode;
5
+ name?: string;
6
+ position?: THREE.Vector3;
7
+ rotation?: THREE.Euler;
8
+ userData?: {
9
+ intangible: boolean;
10
+ };
11
+ onCollisionEnter?: (e: CollisionEnterPayload) => Promise<void>;
12
+ } & import("react").RefAttributes<RapierRigidBody>>;
@@ -0,0 +1,7 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { RigidBody, euler, } from "@react-three/rapier";
3
+ import { forwardRef } from "react";
4
+ export var RigidBodyRef = forwardRef(function (_a, ref) {
5
+ var children = _a.children, name = _a.name, position = _a.position, rotation = _a.rotation, userData = _a.userData, onCollisionEnter = _a.onCollisionEnter;
6
+ return (_jsx(RigidBody, { colliders: false, ref: ref, name: name, position: position, rotation: euler().set(0, (rotation === null || rotation === void 0 ? void 0 : rotation.clone().y) || 0, 0), userData: userData, onCollisionEnter: onCollisionEnter, children: children }));
7
+ });
@@ -0,0 +1,9 @@
1
+ import { Collider } from "@dimforge/rapier3d-compat";
2
+ import { RefObject } from "react";
3
+ import { groundRayType } from "../../../controller/type";
4
+ export type setGroundRayType = {
5
+ groundRay: groundRayType;
6
+ length: number;
7
+ colliderRef: RefObject<Collider>;
8
+ };
9
+ export declare function setGroundRay({ groundRay, length, colliderRef, }: setGroundRayType): void;
@@ -0,0 +1,14 @@
1
+ import { useRapier } from "@react-three/rapier";
2
+ import { getRayHit } from "../../../utils";
3
+ export function setGroundRay(_a) {
4
+ var _b;
5
+ var groundRay = _a.groundRay, length = _a.length, colliderRef = _a.colliderRef;
6
+ var rapier = useRapier().rapier;
7
+ groundRay.length = length;
8
+ groundRay.rayCast = new rapier.Ray(groundRay.origin, groundRay.dir);
9
+ groundRay.hit = getRayHit({
10
+ ray: groundRay,
11
+ ref: colliderRef,
12
+ });
13
+ groundRay.parent = (_b = groundRay.hit) === null || _b === void 0 ? void 0 : _b.collider.parent();
14
+ }
@@ -0,0 +1,20 @@
1
+ /// <reference types="react" />
2
+ import { CollisionEnterPayload } from "@react-three/rapier";
3
+ import { refsType } from "../../../controller/type";
4
+ import { urlsType } from "../../../world/context/type";
5
+ export type refPropsType = {
6
+ children: React.ReactNode;
7
+ refs: Partial<refsType>;
8
+ urls: urlsType;
9
+ isRiderOn?: boolean;
10
+ enableRiding?: boolean;
11
+ offset?: THREE.Vector3;
12
+ name?: string;
13
+ position?: THREE.Vector3;
14
+ rotation?: THREE.Euler;
15
+ userData?: {
16
+ intangible: boolean;
17
+ };
18
+ currentAnimation?: string;
19
+ onCollisionEnter?: (e: CollisionEnterPayload) => Promise<void>;
20
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,11 @@
1
+ import { ReactNode } from "react";
2
+ import * as THREE from "three";
3
+ import { urlsType } from "../../../world/context/type";
4
+ export type riderRefType = {
5
+ urls: urlsType;
6
+ children?: ReactNode;
7
+ offset?: THREE.Vector3;
8
+ euler?: THREE.Euler;
9
+ currentAnimation?: string;
10
+ };
11
+ export default function RiderRef({ urls, children, offset, euler, currentAnimation, }: riderRefType): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,31 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { useAnimations } from "@react-three/drei";
3
+ import { useGraph } from "@react-three/fiber";
4
+ import { useMemo } from "react";
5
+ import * as THREE from "three";
6
+ import { SkeletonUtils } from "three-stdlib";
7
+ import playActions from "../../../animation/actions";
8
+ import { useGltfAndSize } from "../../../hooks/useGaesupGltf";
9
+ export default function RiderRef(_a) {
10
+ var urls = _a.urls, children = _a.children, offset = _a.offset, euler = _a.euler, currentAnimation = _a.currentAnimation;
11
+ var gltf = useGltfAndSize({ url: urls.characterUrl }).gltf;
12
+ var animations = gltf.animations, scene = gltf.scene;
13
+ var animationResult = useAnimations(animations);
14
+ var animationRef = playActions({
15
+ type: "character",
16
+ animationResult: animationResult,
17
+ currentAnimation: currentAnimation || "ride",
18
+ }).animationRef;
19
+ var characterClone = useMemo(function () { return SkeletonUtils.clone(scene); }, [scene]);
20
+ var characterNodes = useGraph(characterClone).nodes;
21
+ var characterObjectNode = Object.values(characterNodes).find(function (node) { return node.type === "Object3D"; });
22
+ return (_jsx(_Fragment, { children: _jsxs("group", { position: offset, rotation: euler, children: [characterObjectNode && (_jsx("primitive", { object: characterObjectNode, visible: false, receiveShadow: true, castShadow: true, ref: animationRef })), Object.keys(characterNodes).map(function (name, key) {
23
+ var characterNode = characterNodes[name];
24
+ if (characterNode instanceof THREE.SkinnedMesh) {
25
+ return (_jsx("skinnedMesh", { castShadow: true, receiveShadow: true, material: characterNode.material, geometry: characterNode.geometry, skeleton: characterNode.skeleton }, key));
26
+ }
27
+ else if (characterNode instanceof THREE.Mesh) {
28
+ return (_jsx("mesh", { castShadow: true, receiveShadow: true, material: characterNode.material, geometry: characterNode.geometry }, key));
29
+ }
30
+ }), children] }) }));
31
+ }
@@ -0,0 +1,10 @@
1
+ /// <reference types="react" />
2
+ import { Collider } from "@dimforge/rapier3d-compat";
3
+ import { urlsType } from "../../../world/context/type";
4
+ export declare const VehicleWheelCollider: import("react").ForwardRefExoticComponent<{
5
+ urls: urlsType;
6
+ vehicleSize: THREE.Vector3;
7
+ } & import("react").RefAttributes<Collider>>;
8
+ export declare const VehicleCollider: import("react").ForwardRefExoticComponent<{
9
+ vehicleSize: THREE.Vector3;
10
+ } & import("react").RefAttributes<Collider>>;
@@ -0,0 +1,19 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { CuboidCollider } from "@react-three/rapier";
3
+ import { forwardRef } from "react";
4
+ import { useGltfAndSize } from "../../../hooks/useGaesupGltf";
5
+ export var VehicleWheelCollider = forwardRef(function (_a, ref) {
6
+ var urls = _a.urls, vehicleSize = _a.vehicleSize;
7
+ var wheelSize = useGltfAndSize({
8
+ url: urls.wheelUrl,
9
+ }).size;
10
+ return (_jsx(CuboidCollider, { ref: ref, args: [
11
+ vehicleSize.x / 2,
12
+ vehicleSize.y / 2 - wheelSize.y / 2,
13
+ vehicleSize.z / 2,
14
+ ], position: [0, vehicleSize.y / 2 + wheelSize.y / 2, 0] }));
15
+ });
16
+ export var VehicleCollider = forwardRef(function (_a, ref) {
17
+ var vehicleSize = _a.vehicleSize;
18
+ return (_jsx(CuboidCollider, { ref: ref, args: [vehicleSize.x / 2, vehicleSize.y / 2, vehicleSize.z / 2], position: [0, vehicleSize.y / 2, 0] }));
19
+ });
@@ -0,0 +1,2 @@
1
+ import { refPropsType } from "../common/type";
2
+ export declare function VehicleInnerRef({ children, refs, urls, isRiderOn, enableRiding, offset, name, position, rotation, userData, currentAnimation, onCollisionEnter, }: refPropsType): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,17 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useGltfAndSize } from "../../../hooks/useGaesupGltf";
3
+ import { InnerGroupRef } from "../common/InnerGroupRef";
4
+ import { OuterGroupRef } from "../common/OuterGroupRef";
5
+ import { RigidBodyRef } from "../common/RigidbodyRef";
6
+ import RiderRef from "../rider";
7
+ import { VehicleCollider, VehicleWheelCollider } from "./collider";
8
+ import { WheelsRef } from "./wheels";
9
+ export function VehicleInnerRef(_a) {
10
+ var children = _a.children, refs = _a.refs, urls = _a.urls, isRiderOn = _a.isRiderOn, enableRiding = _a.enableRiding, offset = _a.offset, name = _a.name, position = _a.position, rotation = _a.rotation, userData = _a.userData, currentAnimation = _a.currentAnimation, onCollisionEnter = _a.onCollisionEnter;
11
+ var vehicleUrl = urls.vehicleUrl, wheelUrl = urls.wheelUrl;
12
+ var rigidBodyRef = refs.rigidBodyRef, innerGroupRef = refs.innerGroupRef, outerGroupRef = refs.outerGroupRef;
13
+ var vehicleSize = useGltfAndSize({
14
+ url: urls.vehicleUrl,
15
+ }).size;
16
+ return (_jsxs(OuterGroupRef, { ref: outerGroupRef, children: [vehicleUrl && rigidBodyRef && (_jsxs(RigidBodyRef, { ref: rigidBodyRef, name: name, position: position, rotation: rotation, userData: userData, onCollisionEnter: onCollisionEnter, children: [wheelUrl ? (_jsx(VehicleWheelCollider, { urls: urls, vehicleSize: vehicleSize })) : (_jsx(VehicleCollider, { vehicleSize: vehicleSize })), enableRiding && isRiderOn && urls.characterUrl && (_jsx(RiderRef, { urls: urls, offset: offset })), children, _jsx(InnerGroupRef, { type: "vehicle", url: vehicleUrl, currentAnimation: currentAnimation, ref: innerGroupRef })] })), wheelUrl && (_jsx(WheelsRef, { refs: refs, urls: urls, vehicleSize: vehicleSize }))] }));
17
+ }
@@ -0,0 +1,7 @@
1
+ import { refsType } from "../../../controller/type";
2
+ import { urlsType } from "../../../world/context/type";
3
+ export declare function WheelsRef({ vehicleSize, refs, urls, }: {
4
+ vehicleSize: THREE.Vector3;
5
+ refs: Partial<refsType>;
6
+ urls: urlsType;
7
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,64 @@
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Gltf } from "@react-three/drei";
3
+ import { useFrame } from "@react-three/fiber";
4
+ import { CylinderCollider, RigidBody, useRevoluteJoint, } from "@react-three/rapier";
5
+ import { createRef, useContext, useRef } from "react";
6
+ import { useGltfAndSize } from "../../../hooks/useGaesupGltf";
7
+ import { GaesupWorldContext } from "../../../world/context";
8
+ var WheelJoint = function (_a) {
9
+ var body = _a.body, wheel = _a.wheel, bodyAnchor = _a.bodyAnchor, wheelAnchor = _a.wheelAnchor, rotationAxis = _a.rotationAxis;
10
+ var joint = useRevoluteJoint(body, wheel, [
11
+ bodyAnchor,
12
+ wheelAnchor,
13
+ rotationAxis,
14
+ ]);
15
+ var activeState = useContext(GaesupWorldContext).activeState;
16
+ useFrame(function () {
17
+ if (joint.current) {
18
+ joint.current.configureMotorPosition(activeState.position.length(), 0.8, 0);
19
+ }
20
+ });
21
+ return null;
22
+ };
23
+ export function WheelsRef(_a) {
24
+ var vehicleSize = _a.vehicleSize, refs = _a.refs, urls = _a.urls;
25
+ var wheelUrl = urls.wheelUrl;
26
+ var rigidBodyRef = refs.rigidBodyRef;
27
+ var wheelSize = useGltfAndSize({
28
+ url: urls.wheelUrl,
29
+ }).size;
30
+ var X = (vehicleSize.x - wheelSize.x) / 2;
31
+ var Z = (vehicleSize.z - 2 * wheelSize.z) / 2;
32
+ var wheelPositions = [
33
+ [-X, 0, Z],
34
+ [-X, 0, -Z],
35
+ [X, 0, Z],
36
+ [X, 0, -Z],
37
+ ];
38
+ var wheelRefs = useRef(wheelPositions.map(function () { return createRef(); }));
39
+ return (_jsxs(_Fragment, { children: [rigidBodyRef &&
40
+ wheelUrl &&
41
+ wheelRefs &&
42
+ wheelPositions.map(function (wheelPosition, index) {
43
+ if (!wheelRefs ||
44
+ !wheelRefs.current ||
45
+ !wheelRefs.current[index] ||
46
+ !wheelSize.x ||
47
+ !wheelSize.y)
48
+ return _jsx(_Fragment, {});
49
+ var wheelRef = wheelRefs.current[index];
50
+ return (_jsxs(RigidBody, { position: wheelPosition, colliders: false, type: "dynamic", ref: wheelRef, rotation: [0, 0, Math.PI / 2], children: [_jsx(CylinderCollider, { rotation: [0, 0, Math.PI / 2], args: [wheelSize.x / 2, wheelSize.y / 2] }), _jsx(Gltf, { src: wheelUrl })] }, index));
51
+ }), rigidBodyRef &&
52
+ wheelUrl &&
53
+ wheelRefs &&
54
+ wheelPositions.map(function (wheelPosition, index) {
55
+ if (!wheelRefs ||
56
+ !wheelRefs.current ||
57
+ !wheelRefs.current[index] ||
58
+ !wheelSize.x ||
59
+ !wheelSize.y)
60
+ return _jsx(_Fragment, {});
61
+ var wheelRef = wheelRefs.current[index];
62
+ return (_jsx(WheelJoint, { body: rigidBodyRef, wheel: wheelRef, bodyAnchor: wheelPosition, wheelAnchor: [0, 0, 0], rotationAxis: [1, 0, 0] }, index));
63
+ })] }));
64
+ }
@@ -0,0 +1,13 @@
1
+ /// <reference types="react" />
2
+ import { CollisionEnterPayload } from "@react-three/rapier";
3
+ import { urlsType } from "../../../world/context/type";
4
+ export type passiveAirplanePropsType = {
5
+ position: THREE.Vector3;
6
+ euler: THREE.Euler;
7
+ urls: urlsType;
8
+ currentAnimation: string;
9
+ offset?: THREE.Vector3;
10
+ children?: React.ReactNode;
11
+ onCollisionEnter?: (e: CollisionEnterPayload) => Promise<void>;
12
+ };
13
+ export declare function PassiveAirplane(props: passiveAirplanePropsType): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,40 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useFrame } from "@react-three/fiber";
3
+ import { quat, } from "@react-three/rapier";
4
+ import { useMemo, useRef } from "react";
5
+ import { AirplaneInnerRef } from "../../inner/airplane";
6
+ export function PassiveAirplane(props) {
7
+ var rigidBodyRef = useRef(null);
8
+ var outerGroupRef = useRef(null);
9
+ var innerGroupRef = useRef(null);
10
+ var colliderRef = useRef(null);
11
+ var refs = {
12
+ rigidBodyRef: rigidBodyRef,
13
+ outerGroupRef: outerGroupRef,
14
+ innerGroupRef: innerGroupRef,
15
+ colliderRef: colliderRef,
16
+ };
17
+ var _a = useMemo(function () {
18
+ return {
19
+ position: props.position,
20
+ euler: props.euler,
21
+ currentAnimation: props.currentAnimation,
22
+ urls: props.urls,
23
+ };
24
+ }, [props]), position = _a.position, euler = _a.euler, currentAnimation = _a.currentAnimation, urls = _a.urls;
25
+ useFrame(function () {
26
+ if (innerGroupRef && innerGroupRef.current) {
27
+ var _euler = euler.clone();
28
+ _euler.y = 0;
29
+ innerGroupRef.current.setRotationFromQuaternion(quat()
30
+ .setFromEuler(innerGroupRef.current.rotation.clone())
31
+ .slerp(quat().setFromEuler(_euler), 0.2));
32
+ }
33
+ if (rigidBodyRef && rigidBodyRef.current) {
34
+ rigidBodyRef.current.setGravityScale(props.position.y < 10
35
+ ? ((1 - 0.1) / (0 - 10)) * props.position.y + 1
36
+ : 0.1, false);
37
+ }
38
+ });
39
+ return (_jsx(AirplaneInnerRef, { refs: refs, urls: urls, position: position, rotation: euler, userData: { intangible: true }, onCollisionEnter: props.onCollisionEnter, currentAnimation: props.currentAnimation, children: props.children }));
40
+ }
@@ -0,0 +1,10 @@
1
+ /// <reference types="react" />
2
+ import { urlsType } from "../../../world/context/type";
3
+ export type passiveCharacterPropsType = {
4
+ position: THREE.Vector3;
5
+ euler: THREE.Euler;
6
+ urls: urlsType;
7
+ currentAnimation: string;
8
+ children?: React.ReactNode;
9
+ };
10
+ export declare function PassiveCharacter(props: passiveCharacterPropsType): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,46 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useAnimations } from "@react-three/drei";
3
+ import { useFrame } from "@react-three/fiber";
4
+ import { quat } from "@react-three/rapier";
5
+ import { useEffect, useMemo, useRef } from "react";
6
+ import playActions from "../../../animation/actions";
7
+ import { useGltfAndSize } from "../../../hooks/useGaesupGltf";
8
+ import { CharacterInnerRef } from "../../inner/character";
9
+ export function PassiveCharacter(props) {
10
+ var rigidBodyRef = useRef(null);
11
+ var outerGroupRef = useRef(null);
12
+ var innerGroupRef = useRef(null);
13
+ var colliderRef = useRef(null);
14
+ var refs = {
15
+ rigidBodyRef: rigidBodyRef,
16
+ outerGroupRef: outerGroupRef,
17
+ innerGroupRef: innerGroupRef,
18
+ colliderRef: colliderRef,
19
+ };
20
+ var _a = useMemo(function () {
21
+ return {
22
+ position: props.position,
23
+ euler: props.euler,
24
+ currentAnimation: props.currentAnimation,
25
+ characterUrl: props.urls.characterUrl,
26
+ };
27
+ }, [props]), position = _a.position, euler = _a.euler, currentAnimation = _a.currentAnimation;
28
+ useEffect(function () {
29
+ if (rigidBodyRef || rigidBodyRef.current) {
30
+ rigidBodyRef.current.setEnabledRotations(false, false, false, false);
31
+ }
32
+ }, []);
33
+ useFrame(function (_, delta) {
34
+ if (innerGroupRef && innerGroupRef.current) {
35
+ innerGroupRef.current.quaternion.rotateTowards(quat().setFromEuler(euler), 10 * delta);
36
+ }
37
+ });
38
+ var gltf = useGltfAndSize({ url: props.urls.characterUrl }).gltf;
39
+ var animationResult = useAnimations(gltf.animations);
40
+ var animationRef = playActions({
41
+ type: "character",
42
+ animationResult: animationResult,
43
+ currentAnimation: currentAnimation,
44
+ }).animationRef;
45
+ return (_jsx(CharacterInnerRef, { animationRef: animationRef, position: position, refs: refs, urls: props.urls, children: props.children }));
46
+ }
@@ -0,0 +1,20 @@
1
+ import { gaesupPassivePropsType } from "../../hooks/useGaesupController";
2
+ import { activeStateType, modeType, wheelsStateType } from "../../world/context/type";
3
+ export type passiveComponentType = {
4
+ props: gaesupPassivePropsType;
5
+ };
6
+ export type passiveCharacterType = {
7
+ mode: modeType;
8
+ state: activeStateType;
9
+ current: string;
10
+ url: string;
11
+ };
12
+ export type passiveVehicleType = {
13
+ mode: modeType;
14
+ state: activeStateType;
15
+ wheelsState?: wheelsStateType;
16
+ wheelPositions?: number[][];
17
+ current: string;
18
+ url: string;
19
+ wheelUrl?: string;
20
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,13 @@
1
+ /// <reference types="react" />
2
+ import { CollisionEnterPayload } from "@react-three/rapier";
3
+ import { urlsType } from "../../../world/context/type";
4
+ export type passiveVehiclePropsType = {
5
+ position: THREE.Vector3;
6
+ euler: THREE.Euler;
7
+ urls: urlsType;
8
+ currentAnimation: string;
9
+ children?: React.ReactNode;
10
+ offset?: THREE.Vector3;
11
+ onCollisionEnter?: (e: CollisionEnterPayload) => Promise<void>;
12
+ };
13
+ export declare function PassiveVehicle(props: passiveVehiclePropsType): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,17 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useRef } from "react";
3
+ import { VehicleInnerRef } from "../../inner/vehicle";
4
+ export function PassiveVehicle(props) {
5
+ var rigidBodyRef = useRef(null);
6
+ var outerGroupRef = useRef(null);
7
+ var innerGroupRef = useRef(null);
8
+ var colliderRef = useRef(null);
9
+ var refs = {
10
+ rigidBodyRef: rigidBodyRef,
11
+ outerGroupRef: outerGroupRef,
12
+ innerGroupRef: innerGroupRef,
13
+ colliderRef: colliderRef,
14
+ };
15
+ var position = props.position, euler = props.euler, currentAnimation = props.currentAnimation, urls = props.urls;
16
+ return (_jsx(VehicleInnerRef, { refs: refs, urls: urls, position: position, rotation: euler, userData: { intangible: true }, onCollisionEnter: props.onCollisionEnter, currentAnimation: currentAnimation, children: props.children }));
17
+ }
@@ -0,0 +1,17 @@
1
+ import { ObjectMap } from "@react-three/fiber";
2
+ import { RapierRigidBody } from "@react-three/rapier";
3
+ import { RefObject } from "react";
4
+ import { GLTF } from "three-stdlib";
5
+ export type GLTFResult = GLTF & {
6
+ nodes: {
7
+ [name: string]: THREE.Mesh | THREE.SkinnedMesh;
8
+ };
9
+ materials: {
10
+ [name: string]: THREE.Material | THREE.MeshStandardMaterial;
11
+ };
12
+ } & ObjectMap;
13
+ export type passiveRefsType = {
14
+ rigidBodyRef: RefObject<RapierRigidBody>;
15
+ outerGroupRef: RefObject<THREE.Group>;
16
+ innerGroupRef: RefObject<THREE.Group>;
17
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,49 @@
1
+ /// <reference types="react" />
2
+ import { dispatchType } from "../../utils/type";
3
+ import { gaesupControllerType } from "./type";
4
+ export declare const gaesupControllerDefault: {
5
+ airplane: {
6
+ angleDelta: import("three").Vector3;
7
+ maxAngle: import("three").Vector3;
8
+ maxSpeed: number;
9
+ accelRatio: number;
10
+ brakeRatio: number;
11
+ buoyancy: number;
12
+ linearDamping: number;
13
+ };
14
+ vehicle: {
15
+ maxSpeed: number;
16
+ accelRatio: number;
17
+ brakeRatio: number;
18
+ wheelOffset: number;
19
+ linearDamping: number;
20
+ };
21
+ character: {
22
+ walkSpeed: number;
23
+ runSpeed: number;
24
+ turnSpeed: number;
25
+ jumpSpeed: number;
26
+ linearDamping: number;
27
+ };
28
+ callbacks: {
29
+ onReady: () => void;
30
+ onFrame: () => void;
31
+ onDestory: () => void;
32
+ onAnimate: () => void;
33
+ };
34
+ refs: {
35
+ colliderRef: any;
36
+ rigidBodyRef: any;
37
+ outerGroupRef: any;
38
+ innerGroupRef: any;
39
+ characterInnerRef: any;
40
+ };
41
+ urls: {
42
+ airplaneUrl: any;
43
+ vehicleUrl: any;
44
+ characterUrl: any;
45
+ wheelUrl: any;
46
+ };
47
+ };
48
+ export declare const GaesupControllerContext: import("react").Context<gaesupControllerType>;
49
+ export declare const GaesupControllerDispatchContext: import("react").Context<dispatchType<gaesupControllerType>>;
@@ -0,0 +1,59 @@
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 { createContext } from "react";
13
+ import { V3 } from "../../utils/vector";
14
+ export var gaesupControllerDefault = {
15
+ airplane: {
16
+ angleDelta: V3(Math.PI / 256, Math.PI / 256, Math.PI / 256),
17
+ maxAngle: V3(Math.PI / 8, Math.PI / 8, Math.PI / 8),
18
+ maxSpeed: 60,
19
+ accelRatio: 2,
20
+ brakeRatio: 5,
21
+ buoyancy: 0.2,
22
+ linearDamping: 1,
23
+ },
24
+ vehicle: {
25
+ maxSpeed: 60,
26
+ accelRatio: 2,
27
+ brakeRatio: 5,
28
+ wheelOffset: 0.1,
29
+ linearDamping: 0.5,
30
+ },
31
+ character: {
32
+ walkSpeed: 10,
33
+ runSpeed: 20,
34
+ turnSpeed: 10,
35
+ jumpSpeed: 1,
36
+ linearDamping: 1,
37
+ },
38
+ callbacks: {
39
+ onReady: function () { },
40
+ onFrame: function () { },
41
+ onDestory: function () { },
42
+ onAnimate: function () { },
43
+ },
44
+ refs: {
45
+ colliderRef: null,
46
+ rigidBodyRef: null,
47
+ outerGroupRef: null,
48
+ innerGroupRef: null,
49
+ characterInnerRef: null,
50
+ },
51
+ urls: {
52
+ airplaneUrl: null,
53
+ vehicleUrl: null,
54
+ characterUrl: null,
55
+ wheelUrl: null,
56
+ },
57
+ };
58
+ export var GaesupControllerContext = createContext(__assign({}, gaesupControllerDefault));
59
+ export var GaesupControllerDispatchContext = createContext(null);
@@ -0,0 +1,12 @@
1
+ import { gaesupControllerType } from "./type";
2
+ export declare function gaesupControllerReducer(props: gaesupControllerType, action: {
3
+ type: string;
4
+ payload?: Partial<gaesupControllerType>;
5
+ }): {
6
+ airplane: import("./type").airplaneType;
7
+ vehicle: import("./type").vehicleType;
8
+ character: import("./type").characterType;
9
+ urls: import("../../world/context/type").urlsType;
10
+ callbacks?: import("../initialize/callback/type").callbackType;
11
+ refs?: import("../type").refsType;
12
+ };
@@ -0,0 +1,21 @@
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 function gaesupControllerReducer(props, action) {
13
+ switch (action.type) {
14
+ case "init": {
15
+ return __assign({}, props);
16
+ }
17
+ case "update": {
18
+ return __assign(__assign({}, props), action.payload);
19
+ }
20
+ }
21
+ }