gaesup-world 0.0.692 → 0.0.761

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 (152) hide show
  1. package/dist/gaesup/animation/actions.d.ts +21 -5
  2. package/dist/gaesup/animation/actions.js +60 -45
  3. package/dist/gaesup/camera/control/normal.js +2 -2
  4. package/dist/gaesup/camera/detector/index.d.ts +2 -0
  5. package/dist/gaesup/camera/detector/index.js +25 -0
  6. package/dist/gaesup/camera/index.js +11 -8
  7. package/dist/gaesup/camera/type.d.ts +3 -7
  8. package/dist/gaesup/component/{ref → active}/airplane/collider.d.ts +1 -1
  9. package/dist/gaesup/component/{ref → active}/airplane/collider.js +2 -2
  10. package/dist/gaesup/component/active/airplane/index.js +11 -0
  11. package/dist/gaesup/component/{ref → active}/character/collider.js +2 -2
  12. package/dist/gaesup/component/{ref → active}/character/index.d.ts +1 -2
  13. package/dist/gaesup/component/active/character/index.js +16 -0
  14. package/dist/gaesup/component/active/common/InnerGroupRef.d.ts +10 -0
  15. package/dist/gaesup/component/active/common/InnerGroupRef.js +32 -0
  16. package/dist/gaesup/component/{ref/airplane/group.d.ts → active/common/OuterGroupRef.d.ts} +1 -1
  17. package/dist/gaesup/component/{ref/character/group.js → active/common/OuterGroupRef.js} +2 -2
  18. package/dist/gaesup/component/{ref/vehicle/rigidbody.d.ts → active/common/RigidbodyRef.d.ts} +1 -1
  19. package/dist/gaesup/component/{ref/vehicle/group.js → active/common/RigidbodyRef.js} +4 -5
  20. package/dist/gaesup/component/active/common/WrapperRef.d.ts +12 -0
  21. package/dist/gaesup/component/active/common/WrapperRef.js +9 -0
  22. package/dist/gaesup/component/{ref/character/slopeRay.d.ts → active/common/slopeRayRef.d.ts} +1 -1
  23. package/dist/gaesup/component/{ref/character/slopeRay.js → active/common/slopeRayRef.js} +2 -2
  24. package/dist/gaesup/component/active/vehicle/index.js +12 -0
  25. package/dist/gaesup/component/{ref → active}/vehicle/wheel.d.ts +1 -0
  26. package/dist/gaesup/component/{ref → active}/vehicle/wheel.js +4 -3
  27. package/dist/gaesup/component/{ref → active}/vehicle/wheels.d.ts +3 -0
  28. package/dist/gaesup/component/{ref → active}/vehicle/wheels.js +1 -1
  29. package/dist/gaesup/component/index.d.ts +2 -0
  30. package/dist/gaesup/component/index.js +13 -4
  31. package/dist/gaesup/component/passive/airplane/collider.d.ts +6 -0
  32. package/dist/gaesup/component/passive/airplane/collider.js +8 -0
  33. package/dist/gaesup/component/passive/airplane/index.d.ts +4 -0
  34. package/dist/gaesup/component/passive/airplane/index.js +25 -0
  35. package/dist/gaesup/component/passive/character/collider.d.ts +6 -0
  36. package/dist/gaesup/component/passive/character/collider.js +7 -0
  37. package/dist/gaesup/component/passive/character/index.d.ts +4 -0
  38. package/dist/gaesup/component/passive/character/index.js +25 -0
  39. package/dist/gaesup/component/passive/common/InnerGroupRef.d.ts +8 -0
  40. package/dist/gaesup/component/passive/common/InnerGroupRef.js +27 -0
  41. package/dist/gaesup/component/{ref/character/outerGroup.d.ts → passive/common/OuterGroupRef.d.ts} +1 -1
  42. package/dist/gaesup/component/passive/common/OuterGroupRef.js +6 -0
  43. package/dist/gaesup/component/passive/common/PassiveWrapperRef.d.ts +10 -0
  44. package/dist/gaesup/component/passive/common/PassiveWrapperRef.js +8 -0
  45. package/dist/gaesup/component/passive/{passiveCharacter/rigidbody.d.ts → common/RigidbodyRef.d.ts} +1 -1
  46. package/dist/gaesup/component/passive/common/RigidbodyRef.js +7 -0
  47. package/dist/gaesup/component/passive/type.d.ts +21 -2
  48. package/dist/gaesup/component/passive/vehicle/collider.d.ts +7 -0
  49. package/dist/gaesup/component/passive/vehicle/collider.js +8 -0
  50. package/dist/gaesup/component/passive/vehicle/index.d.ts +4 -0
  51. package/dist/gaesup/component/passive/vehicle/index.js +26 -0
  52. package/dist/gaesup/component/passive/vehicle/wheel.d.ts +16 -0
  53. package/dist/gaesup/component/passive/vehicle/wheel.js +10 -0
  54. package/dist/gaesup/component/passive/vehicle/wheels.d.ts +11 -0
  55. package/dist/gaesup/component/passive/vehicle/wheels.js +27 -0
  56. package/dist/gaesup/component/type.d.ts +8 -0
  57. package/dist/gaesup/controller/context/index.js +0 -1
  58. package/dist/gaesup/controller/context/reducer.d.ts +2 -2
  59. package/dist/gaesup/controller/context/type.d.ts +3 -3
  60. package/dist/gaesup/controller/debug/index.js +2 -0
  61. package/dist/gaesup/controller/index.js +1 -15
  62. package/dist/gaesup/controller/initialize/index.d.ts +2 -16
  63. package/dist/gaesup/controller/initialize/index.js +8 -11
  64. package/dist/gaesup/controller/type.d.ts +1 -2
  65. package/dist/gaesup/hooks/useGaesupController/index.d.ts +11 -5
  66. package/dist/gaesup/hooks/useGaesupController/index.js +6 -0
  67. package/dist/gaesup/index.d.ts +1 -1
  68. package/dist/gaesup/index.js +1 -1
  69. package/dist/gaesup/mutation/airplane/index.d.ts +2 -0
  70. package/dist/gaesup/mutation/airplane/index.js +6 -0
  71. package/dist/gaesup/mutation/airplane/rotation.d.ts +2 -0
  72. package/dist/gaesup/mutation/airplane/rotation.js +9 -0
  73. package/dist/gaesup/mutation/character/index.js +2 -2
  74. package/dist/gaesup/mutation/character/rotation.js +3 -3
  75. package/dist/gaesup/mutation/index.d.ts +7 -2
  76. package/dist/gaesup/mutation/index.js +17 -4
  77. package/dist/gaesup/mutation/type.d.ts +3 -0
  78. package/dist/gaesup/mutation/vehicle/index.d.ts +2 -0
  79. package/dist/gaesup/mutation/vehicle/index.js +6 -0
  80. package/dist/gaesup/mutation/vehicle/rotation.d.ts +2 -0
  81. package/dist/gaesup/mutation/vehicle/rotation.js +5 -0
  82. package/dist/gaesup/physics/airplane/direction.js +1 -0
  83. package/dist/gaesup/physics/airplane/impulse.js +1 -1
  84. package/dist/gaesup/physics/character/direction.js +8 -9
  85. package/dist/gaesup/physics/character/impulse.js +1 -1
  86. package/dist/gaesup/physics/character/jump.js +1 -1
  87. package/dist/gaesup/physics/character/turn.js +6 -2
  88. package/dist/gaesup/physics/type.d.ts +5 -2
  89. package/dist/gaesup/tools/minimap/index.js +5 -3
  90. package/dist/gaesup/tools/minimap/type.d.ts +2 -0
  91. package/dist/gaesup/world/context/index.js +1 -6
  92. package/dist/gaesup/world/context/type.d.ts +17 -6
  93. package/dist/gaesup/world/debug/index.js +3 -0
  94. package/dist/gaesup/world/initalize/index.js +1 -20
  95. package/dist/styles/sprinkles/color.css.d.ts +2 -2
  96. package/dist/styles/sprinkles/direction.css.d.ts +8 -8
  97. package/dist/styles/sprinkles/display.css.d.ts +3 -3
  98. package/dist/styles/sprinkles/fontSize.css.d.ts +4 -4
  99. package/dist/styles/sprinkles/index.css.d.ts +228 -228
  100. package/dist/styles/sprinkles/margin.css.d.ts +50 -50
  101. package/dist/styles/sprinkles/padding.css.d.ts +50 -50
  102. package/package.json +1 -1
  103. package/dist/gaesup/camera/cameraCollisionDetecter.d.ts +0 -4
  104. package/dist/gaesup/camera/cameraCollisionDetecter.js +0 -50
  105. package/dist/gaesup/component/mode/Airplane.d.ts +0 -5
  106. package/dist/gaesup/component/mode/Airplane.js +0 -8
  107. package/dist/gaesup/component/mode/Character.d.ts +0 -5
  108. package/dist/gaesup/component/mode/Character.js +0 -8
  109. package/dist/gaesup/component/mode/Vehicle.d.ts +0 -5
  110. package/dist/gaesup/component/mode/Vehicle.js +0 -8
  111. package/dist/gaesup/component/mode/index.d.ts +0 -3
  112. package/dist/gaesup/component/mode/index.js +0 -3
  113. package/dist/gaesup/component/passive/Airplane.d.ts +0 -5
  114. package/dist/gaesup/component/passive/Airplane.js +0 -8
  115. package/dist/gaesup/component/passive/Vehicle.d.ts +0 -5
  116. package/dist/gaesup/component/passive/Vehicle.js +0 -8
  117. package/dist/gaesup/component/passive/index.d.ts +0 -3
  118. package/dist/gaesup/component/passive/index.js +0 -3
  119. package/dist/gaesup/component/passive/passiveCharacter/index.d.ts +0 -2
  120. package/dist/gaesup/component/passive/passiveCharacter/index.js +0 -20
  121. package/dist/gaesup/component/passive/passiveCharacter/innerGltf.d.ts +0 -3
  122. package/dist/gaesup/component/passive/passiveCharacter/innerGltf.js +0 -24
  123. package/dist/gaesup/component/passive/passiveCharacter/outerGroup.d.ts +0 -4
  124. package/dist/gaesup/component/passive/passiveCharacter/outerGroup.js +0 -8
  125. package/dist/gaesup/component/passive/passiveCharacter/rigidbody.js +0 -7
  126. package/dist/gaesup/component/ref/airplane/group.js +0 -19
  127. package/dist/gaesup/component/ref/airplane/index.js +0 -10
  128. package/dist/gaesup/component/ref/airplane/innerGltf.d.ts +0 -2
  129. package/dist/gaesup/component/ref/airplane/innerGltf.js +0 -13
  130. package/dist/gaesup/component/ref/airplane/rigidbody.d.ts +0 -7
  131. package/dist/gaesup/component/ref/airplane/rigidbody.js +0 -22
  132. package/dist/gaesup/component/ref/character/group.d.ts +0 -6
  133. package/dist/gaesup/component/ref/character/index.js +0 -13
  134. package/dist/gaesup/component/ref/character/innerGltf.d.ts +0 -11
  135. package/dist/gaesup/component/ref/character/innerGltf.js +0 -45
  136. package/dist/gaesup/component/ref/character/outerGroup.js +0 -8
  137. package/dist/gaesup/component/ref/character/rigidbody.d.ts +0 -7
  138. package/dist/gaesup/component/ref/character/rigidbody.js +0 -22
  139. package/dist/gaesup/component/ref/vehicle/group.d.ts +0 -6
  140. package/dist/gaesup/component/ref/vehicle/index.js +0 -14
  141. package/dist/gaesup/component/ref/vehicle/innerGltf.d.ts +0 -2
  142. package/dist/gaesup/component/ref/vehicle/innerGltf.js +0 -13
  143. package/dist/gaesup/component/ref/vehicle/rigidbody.js +0 -22
  144. /package/dist/gaesup/component/{ref → active}/airplane/index.d.ts +0 -0
  145. /package/dist/gaesup/component/{ref → active}/character/collider.d.ts +0 -0
  146. /package/dist/gaesup/component/{ref → active}/vehicle/collider.d.ts +0 -0
  147. /package/dist/gaesup/component/{ref → active}/vehicle/collider.js +0 -0
  148. /package/dist/gaesup/component/{ref → active}/vehicle/index.d.ts +0 -0
  149. /package/dist/gaesup/mutation/{character → common}/stabilizing.d.ts +0 -0
  150. /package/dist/gaesup/mutation/{character → common}/stabilizing.js +0 -0
  151. /package/dist/gaesup/mutation/{character → common}/transition.d.ts +0 -0
  152. /package/dist/gaesup/mutation/{character → common}/transition.js +0 -0
@@ -1,9 +1,25 @@
1
- /// <reference types="react" />
2
- import { groundRayType } from "../controller/type";
1
+ import { Ref } from "react";
2
+ import { Object3D, Object3DEventMap } from "three";
3
+ import { animationTagType, groundRayType } from "../controller/type";
3
4
  export type playActionsType = {
4
5
  groundRay: groundRayType;
5
- isRider?: boolean;
6
6
  };
7
- export default function playActions({ groundRay, isRider }: playActionsType): {
8
- animationRef: import("react").MutableRefObject<import("three").Object3D<import("three").Object3DEventMap>>;
7
+ export type actionsType = {
8
+ [x: string]: THREE.AnimationAction | null;
9
+ };
10
+ export type playResultType = {
11
+ actions: actionsType;
12
+ ref: Ref<Object3D<Object3DEventMap>>;
13
+ };
14
+ export declare function usePlayActions(): {
15
+ resultRef: {
16
+ character: playResultType;
17
+ vehicle: playResultType;
18
+ airplane: playResultType;
19
+ };
20
+ play: (tag: keyof animationTagType) => void;
21
+ setAnimationName: (actions: actionsType) => void;
22
+ };
23
+ export default function playCharacterActions({ groundRay }: playActionsType): {
24
+ ref: Ref<Object3D<Object3DEventMap>>;
9
25
  };
@@ -13,43 +13,53 @@ import { useAnimations, useKeyboardControls } from "@react-three/drei";
13
13
  import { useFrame } from "@react-three/fiber";
14
14
  import { useContext, useEffect } from "react";
15
15
  import { GaesupWorldContext, GaesupWorldDispatchContext, } from "../world/context";
16
- export default function playActions(_a) {
17
- var groundRay = _a.groundRay, isRider = _a.isRider;
18
- var _b = useContext(GaesupWorldContext), characterGltf = _b.characterGltf, characterAnimations = _b.animations;
16
+ export function usePlayActions() {
17
+ var _a = useContext(GaesupWorldContext), characterGltf = _a.characterGltf, vehicleGltf = _a.vehicleGltf, airplaneGltf = _a.airplaneGltf, animations = _a.animations;
18
+ var resultRef = {
19
+ character: null,
20
+ vehicle: null,
21
+ airplane: null,
22
+ };
23
+ if (characterGltf && characterGltf.animations) {
24
+ resultRef.character = useAnimations(characterGltf.animations);
25
+ }
26
+ if (vehicleGltf && vehicleGltf.animations) {
27
+ resultRef.vehicle = useAnimations(vehicleGltf.animations);
28
+ }
29
+ if (airplaneGltf && airplaneGltf.animations) {
30
+ resultRef.airplane = useAnimations(airplaneGltf.animations);
31
+ }
19
32
  var dispatch = useContext(GaesupWorldDispatchContext);
20
- var animations = characterGltf.animations;
21
- var control = useKeyboardControls()[1]();
22
- var _c = useAnimations(animations), actions = _c.actions, animationRef = _c.ref;
23
- useEffect(function () {
24
- characterAnimations.keyControl = control;
25
- dispatch({
26
- type: "update",
27
- payload: {
28
- animations: __assign({}, characterAnimations),
29
- },
30
- });
31
- }, [control]);
32
33
  var play = function (tag) {
33
- characterAnimations.current = tag;
34
+ animations.current = tag;
34
35
  dispatch({
35
36
  type: "update",
36
37
  payload: {
37
- animations: __assign({}, characterAnimations),
38
+ animations: __assign({}, animations),
38
39
  },
39
40
  });
40
41
  };
41
42
  var setAnimationName = function (actions) {
42
- characterAnimations.animationNames = Object.assign(characterAnimations.animationNames, Object.keys(actions).reduce(function (acc, cur) {
43
+ animations.animationNames = Object.assign(animations.animationNames, Object.keys(actions).reduce(function (acc, cur) {
43
44
  var _a;
44
45
  return __assign(__assign({}, acc), (_a = {}, _a[cur] = cur, _a));
45
46
  }, {}));
46
47
  dispatch({
47
48
  type: "update",
48
49
  payload: {
49
- animations: __assign({}, characterAnimations),
50
+ animations: __assign({}, animations),
50
51
  },
51
52
  });
52
53
  };
54
+ return { resultRef: resultRef, play: play, setAnimationName: setAnimationName };
55
+ }
56
+ export default function playCharacterActions(_a) {
57
+ var groundRay = _a.groundRay;
58
+ var _b = usePlayActions(), _c = _b.resultRef.character, actions = _c.actions, ref = _c.ref, play = _b.play, setAnimationName = _b.setAnimationName;
59
+ var _d = useContext(GaesupWorldContext), states = _d.states, activeState = _d.activeState, animations = _d.animations, mode = _d.mode;
60
+ var isNotMoving = states.isNotMoving, isMoving = states.isMoving, isJumping = states.isJumping, isRunning = states.isRunning, isAnimationOuter = states.isAnimationOuter, isOnTheGround = states.isOnTheGround;
61
+ var dispatch = useContext(GaesupWorldDispatchContext);
62
+ var control = useKeyboardControls()[1]();
53
63
  var resetAni = function () { return play("idle"); };
54
64
  var playIdle = function () { return play("idle"); };
55
65
  var playWalk = function () { return play("walk"); };
@@ -63,21 +73,27 @@ export default function playActions(_a) {
63
73
  resetAni();
64
74
  };
65
75
  }, []);
76
+ useEffect(function () {
77
+ animations.keyControl = control;
78
+ dispatch({
79
+ type: "update",
80
+ payload: {
81
+ animations: __assign({}, animations),
82
+ },
83
+ });
84
+ }, [control]);
66
85
  useEffect(function () {
67
86
  var _a;
68
- var action = (_a = actions[characterAnimations.current]) === null || _a === void 0 ? void 0 : _a.reset().fadeIn(0.2).play();
69
- setAnimationName(actions);
70
- return function () {
71
- action === null || action === void 0 ? void 0 : action.fadeOut(0.2);
72
- };
73
- }, [characterAnimations.current]);
74
- var _d = useContext(GaesupWorldContext), states = _d.states, activeState = _d.activeState;
75
- var isNotMoving = states.isNotMoving, isMoving = states.isMoving, isJumping = states.isJumping, isRunning = states.isRunning, isAnimationOuter = states.isAnimationOuter, isOnTheGround = states.isOnTheGround;
76
- useFrame(function () {
77
- if (isRider) {
78
- playRide();
87
+ if (mode.type === "character") {
88
+ var action_1 = (_a = actions[animations.current]) === null || _a === void 0 ? void 0 : _a.reset().fadeIn(0.2).play();
89
+ setAnimationName(actions);
90
+ return function () {
91
+ action_1 === null || action_1 === void 0 ? void 0 : action_1.fadeOut(0.2);
92
+ };
79
93
  }
80
- else {
94
+ }, [animations.current, mode.type]);
95
+ useFrame(function () {
96
+ if (mode.type === "character") {
81
97
  if (!isAnimationOuter) {
82
98
  if (isJumping) {
83
99
  playJump();
@@ -91,23 +107,22 @@ export default function playActions(_a) {
91
107
  else if (isMoving) {
92
108
  playWalk();
93
109
  }
94
- if (groundRay.hit) {
95
- if (!isJumping && !isOnTheGround) {
96
- if (groundRay.hit.toi < 5) {
97
- playLanding();
98
- }
99
- else {
100
- playFall();
101
- }
102
- }
103
- }
104
- if (groundRay.hit === null && activeState.velocity.y < 0) {
105
- playFall();
106
- }
110
+ // if (groundRay.hit) {
111
+ // if (!isJumping && !isOnTheGround) {
112
+ // if (groundRay.hit.toi < 5) {
113
+ // playLanding();
114
+ // } else {
115
+ // playFall();
116
+ // }
117
+ // }
118
+ // }
119
+ // if (groundRay.hit === null && activeState.velocity.y < 0) {
120
+ // playFall();
121
+ // }
107
122
  }
108
123
  }
109
124
  });
110
125
  return {
111
- animationRef: animationRef,
126
+ ref: ref,
112
127
  };
113
128
  }
@@ -3,7 +3,7 @@ export default function normal(prop) {
3
3
  var state = prop.state, perspectiveCamera = prop.controllerContext.perspectiveCamera, activeState = prop.worldContext.activeState;
4
4
  var cameraPosition = activeState.position
5
5
  .clone()
6
- .add(V3(perspectiveCamera.XZDistance, perspectiveCamera.YDistance, 0));
7
- state.camera.position.lerp(cameraPosition, 1);
6
+ .add(V3(0, perspectiveCamera.YDistance, perspectiveCamera.XZDistance));
7
+ state.camera.position.lerp(cameraPosition, 0.9);
8
8
  state.camera.lookAt(activeState.position.clone());
9
9
  }
@@ -0,0 +1,2 @@
1
+ import { cameraPropType } from "../../physics/type";
2
+ export default function detector(cameraProp: cameraPropType): void;
@@ -0,0 +1,25 @@
1
+ import * as THREE from "three";
2
+ export default function detector(cameraProp) {
3
+ var cameraRay = cameraProp.cameraRay, intersectObjectMap = cameraProp.intersectObjectMap;
4
+ var intersects = cameraRay.rayCast.intersectObjects(Object.values(intersectObjectMap));
5
+ var intersectId = {};
6
+ intersects.map(function (_a) {
7
+ var object = _a.object;
8
+ if (object instanceof THREE.Mesh) {
9
+ intersectId[object.uuid] = true;
10
+ }
11
+ });
12
+ Object.values(intersectObjectMap).map(function (mesh) {
13
+ if (mesh instanceof THREE.Mesh && mesh.material instanceof THREE.Material) {
14
+ var material = mesh.material;
15
+ if (intersectId[mesh.uuid]) {
16
+ material.opacity = 0.2;
17
+ material.transparent = true;
18
+ }
19
+ else {
20
+ material.opacity = 1;
21
+ material.transparent = false;
22
+ }
23
+ }
24
+ });
25
+ }
@@ -12,11 +12,10 @@ var __assign = (this && this.__assign) || function () {
12
12
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
13
13
  import { MapControls, OrbitControls, OrthographicCamera, PerspectiveCamera, } from "@react-three/drei";
14
14
  import { useFrame, useThree } from "@react-three/fiber";
15
- import { useContext } from "react";
15
+ import { useContext, useEffect, useMemo } from "react";
16
16
  import * as THREE from "three";
17
17
  import { GaesupControllerContext } from "../controller/context";
18
18
  import { GaesupWorldContext } from "../world/context";
19
- import cameraCollisionDetector from "./cameraCollisionDetecter";
20
19
  import mapControl from "./control/map";
21
20
  import normal from "./control/normal";
22
21
  import orbit from "./control/orbit";
@@ -27,11 +26,10 @@ export default function Camera(_a) {
27
26
  var cameraMode = controllerContext.cameraMode, perspectiveCamera = controllerContext.perspectiveCamera, orthographicCamera = controllerContext.orthographicCamera;
28
27
  var rigidBodyRef = refs.rigidBodyRef, outerGroupRef = refs.outerGroupRef;
29
28
  var cameraRay = prop.cameraRay;
30
- var checkCollision = cameraCollisionDetector(prop).checkCollision;
31
- var scene = useThree().scene;
29
+ var _b = useThree(), camera = _b.camera, scene = _b.scene;
32
30
  var activeState = worldContext.activeState;
33
- var intersectObjectMap = {};
34
- var cameraProp = __assign(__assign({}, prop), { checkCollision: checkCollision, control: control, controllerContext: controllerContext, worldContext: worldContext });
31
+ var intersectObjectMap = useMemo(function () { return ({}); }, []);
32
+ var cameraProp = __assign(__assign({}, prop), { control: control, controllerContext: controllerContext, worldContext: worldContext, intersectObjectMap: intersectObjectMap });
35
33
  var getMeshs = function (object) {
36
34
  if (object.userData && object.userData.intangible)
37
35
  return;
@@ -43,6 +41,9 @@ export default function Camera(_a) {
43
41
  getMeshs(child);
44
42
  });
45
43
  };
44
+ useEffect(function () {
45
+ scene.children.forEach(function (child) { return getMeshs(child); });
46
+ }, []);
46
47
  useFrame(function (state, delta) {
47
48
  if (!rigidBodyRef ||
48
49
  !rigidBodyRef.current ||
@@ -52,8 +53,6 @@ export default function Camera(_a) {
52
53
  cameraProp.state = state;
53
54
  cameraProp.delta = delta;
54
55
  if (cameraMode.cameraType === "perspective") {
55
- scene.children.forEach(function (child) { return getMeshs(child); });
56
- cameraRay.intersectObjectMap = intersectObjectMap;
57
56
  if (cameraMode.controlType === "orbit") {
58
57
  orbit(cameraProp);
59
58
  }
@@ -64,6 +63,10 @@ export default function Camera(_a) {
64
63
  else if (cameraMode.cameraType === "orthographic") {
65
64
  mapControl(cameraProp);
66
65
  }
66
+ // const distV3 = camera.position.clone().sub(activeState.position);
67
+ // cameraRay.origin.copy(camera.position);
68
+ // cameraRay.dir.copy(distV3.negate().normalize());
69
+ // detector(cameraProp);
67
70
  });
68
71
  return (_jsxs(_Fragment, { children: [cameraMode.cameraType === "perspective" && (_jsxs(_Fragment, { children: [_jsx(OrbitControls, { target: activeState.position }), _jsx(PerspectiveCamera, __assign({ makeDefault: true }, perspectiveCamera))] })), cameraMode.cameraType === "orthographic" && (_jsxs(_Fragment, { children: [_jsx(MapControls, { target: activeState.position }), _jsx(OrthographicCamera, __assign({ makeDefault: true }, orthographicCamera))] }))] }));
69
72
  }
@@ -2,16 +2,12 @@ export type cameraRayType = {
2
2
  origin: THREE.Vector3;
3
3
  hit: THREE.Raycaster;
4
4
  rayCast: THREE.Raycaster | null;
5
- lerpingPoint: THREE.Vector3;
6
5
  length: number;
7
6
  dir: THREE.Vector3;
8
7
  position: THREE.Vector3;
9
- followCamera: THREE.Object3D;
10
- pivot: THREE.Object3D;
11
- intersetesAndTransParented: THREE.Intersection<THREE.Object3D<THREE.Object3DEventMap>>[];
12
- intersects: THREE.Intersection<THREE.Object3D<THREE.Object3DEventMap>>[];
13
- intersectObjects: THREE.Object3D[];
8
+ intersects: THREE.Intersection<THREE.Mesh>[];
9
+ detected: THREE.Intersection<THREE.Mesh>[];
14
10
  intersectObjectMap: {
15
- [uuid: string]: THREE.Object3D;
11
+ [uuid: string]: THREE.Mesh;
16
12
  };
17
13
  };
@@ -2,5 +2,5 @@
2
2
  import { Collider } from "@dimforge/rapier3d-compat";
3
3
  import { controllerInnerType } from "../../../controller/type";
4
4
  export declare const AirplaneCollider: import("react").ForwardRefExoticComponent<{
5
- prop: controllerInnerType;
5
+ props: controllerInnerType;
6
6
  } & import("react").RefAttributes<Collider>>;
@@ -5,12 +5,12 @@ import { getRayHit, useForwardRef } from "../../../utils";
5
5
  import { GaesupWorldContext } from "../../../world/context";
6
6
  export var AirplaneCollider = forwardRef(function (_a, ref) {
7
7
  var _b;
8
- var prop = _a.prop;
8
+ var props = _a.props;
9
9
  var collider = useContext(GaesupWorldContext).airplaneCollider;
10
10
  var airplaneSizeX = collider.airplaneSizeX, airplaneSizeY = collider.airplaneSizeY, airplaneSizeZ = collider.airplaneSizeZ;
11
11
  var colliderRef = useForwardRef(ref);
12
12
  var rapier = useRapier().rapier;
13
- var groundRay = prop.groundRay;
13
+ var groundRay = props.groundRay;
14
14
  groundRay.length = airplaneSizeY * 5 + 2;
15
15
  groundRay.rayCast = new rapier.Ray(groundRay.origin, groundRay.dir);
16
16
  groundRay.hit = getRayHit({
@@ -0,0 +1,11 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useContext } from "react";
3
+ import { GaesupWorldContext } from "../../../world/context";
4
+ import { InnerGroupRef } from "../common/InnerGroupRef";
5
+ import { WrapperRef } from "../common/WrapperRef";
6
+ import { AirplaneCollider } from "./collider";
7
+ export function AirplaneRef(_a) {
8
+ var props = _a.props, refs = _a.refs;
9
+ var _b = useContext(GaesupWorldContext), characterGltf = _b.characterGltf, airplaneGltf = _b.airplaneGltf;
10
+ return (_jsxs(WrapperRef, { props: props, refs: refs, gltf: airplaneGltf, children: [props.isRider && (_jsx(InnerGroupRef, { props: props, gltf: characterGltf, ref: refs.characterInnerRef })), _jsx(AirplaneCollider, { props: props })] }));
11
+ }
@@ -1,4 +1,4 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
1
+ import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import { CapsuleCollider, useRapier } from "@react-three/rapier";
3
3
  import { forwardRef, useContext } from "react";
4
4
  import { getRayHit, useForwardRef } from "../../../utils";
@@ -20,5 +20,5 @@ export var CharacterCapsuleCollider = forwardRef(function (_a, ref) {
20
20
  slopeRay.rayCast = new rapier.Ray(slopeRay.origin, slopeRay.dir);
21
21
  slopeRay.length = collider.radius + 3;
22
22
  slopeRay.rayCast = new rapier.Ray(slopeRay.origin, slopeRay.dir);
23
- return (_jsx(CapsuleCollider, { ref: ref, args: [collider.height, collider.radius] }));
23
+ return (_jsx(_Fragment, { children: _jsx(CapsuleCollider, { ref: ref, args: [collider.height, collider.radius], position: [0, collider.height + collider.radius, 0] }) }));
24
24
  });
@@ -1,6 +1,5 @@
1
1
  import { controllerInnerType, refsType } from "../../../controller/type";
2
- export declare function CharacterRef({ props, refs, isPassive, }: {
2
+ export declare function CharacterRef({ props, refs, }: {
3
3
  props: controllerInnerType;
4
4
  refs: refsType;
5
- isPassive?: boolean;
6
5
  }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,16 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useContext } from "react";
3
+ import initCallback from "../../../controller/initialize/callback";
4
+ import { GaesupWorldContext } from "../../../world/context";
5
+ import { CharacterCapsuleCollider } from "./collider";
6
+ import playCharacterActions from "../../../animation/actions";
7
+ import { WrapperRef } from "../common/WrapperRef";
8
+ export function CharacterRef(_a) {
9
+ var props = _a.props, refs = _a.refs;
10
+ initCallback(props);
11
+ var _b = useContext(GaesupWorldContext), characterGltf = _b.characterGltf, characterCollider = _b.characterCollider, vehicleCollider = _b.vehicleCollider;
12
+ var ref = playCharacterActions({
13
+ groundRay: props.groundRay,
14
+ }).ref;
15
+ return (_jsx(WrapperRef, { props: props, refs: refs, gltf: characterGltf, animationRef: ref, children: _jsx(CharacterCapsuleCollider, { props: props, ref: refs.capsuleColliderRef }) }));
16
+ }
@@ -0,0 +1,10 @@
1
+ import { Ref } from "react";
2
+ import { controllerInnerType } from "../../../controller/type";
3
+ import * as THREE from "three";
4
+ import { GLTFResult } from "../../type";
5
+ export type InnerGroupRefType = {
6
+ props: controllerInnerType;
7
+ animationRef?: Ref<THREE.Object3D<THREE.Object3DEventMap>>;
8
+ gltf: GLTFResult;
9
+ };
10
+ export declare const InnerGroupRef: import("react").ForwardRefExoticComponent<InnerGroupRefType & import("react").RefAttributes<THREE.Group<THREE.Object3DEventMap>>>;
@@ -0,0 +1,32 @@
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, jsxs as _jsxs } from "react/jsx-runtime";
13
+ import { forwardRef, useMemo } from "react";
14
+ import { useGraph } from "@react-three/fiber";
15
+ import * as THREE from "three";
16
+ import { SkeletonUtils } from "three-stdlib";
17
+ export var InnerGroupRef = forwardRef(function (_a, ref) {
18
+ var props = _a.props, animationRef = _a.animationRef, gltf = _a.gltf;
19
+ var scene = gltf.scene;
20
+ var clone = useMemo(function () { return SkeletonUtils.clone(scene); }, [scene]);
21
+ var nodes = useGraph(clone).nodes;
22
+ var objectNode = Object.values(nodes).find(function (node) { return node.type === "Object3D"; });
23
+ return (_jsxs("group", __assign({ receiveShadow: true, castShadow: true }, props.groupProps, { ref: ref, children: [objectNode && animationRef && (_jsx("primitive", { object: objectNode, visible: false, receiveShadow: true, castShadow: true, ref: animationRef })), Object.keys(nodes).map(function (name, key) {
24
+ var node = nodes[name];
25
+ if (node instanceof THREE.SkinnedMesh) {
26
+ return (_jsx("skinnedMesh", { castShadow: true, receiveShadow: true, material: node.material, geometry: node.geometry, skeleton: node.skeleton }, key));
27
+ }
28
+ else if (node instanceof THREE.Mesh) {
29
+ return (_jsx("mesh", { castShadow: true, receiveShadow: true, material: node.material, geometry: node.geometry }, key));
30
+ }
31
+ })] })));
32
+ });
@@ -1,6 +1,6 @@
1
1
  import { ReactNode } from "react";
2
2
  import { controllerType } from "../../../controller/type";
3
- export declare const AirplaneGroup: import("react").ForwardRefExoticComponent<{
3
+ export declare const OuterGroupRef: import("react").ForwardRefExoticComponent<{
4
4
  props: controllerType;
5
5
  children: ReactNode;
6
6
  } & import("react").RefAttributes<import("three").Group<import("three").Object3DEventMap>>>;
@@ -11,7 +11,7 @@ var __assign = (this && this.__assign) || function () {
11
11
  };
12
12
  import { jsx as _jsx } from "react/jsx-runtime";
13
13
  import { forwardRef } from "react";
14
- export var CharacterGroup = forwardRef(function (_a, ref) {
14
+ export var OuterGroupRef = forwardRef(function (_a, ref) {
15
15
  var props = _a.props, children = _a.children;
16
- return (_jsx("group", __assign({ ref: ref, userData: { intangible: true } }, props.character, { children: children })));
16
+ return (_jsx("group", __assign({ ref: ref, userData: { intangible: true } }, props.vehicle, { children: children })));
17
17
  });
@@ -1,7 +1,7 @@
1
1
  import { RapierRigidBody } from "@react-three/rapier";
2
2
  import { ReactNode } from "react";
3
3
  import { controllerInnerType } from "../../../controller/type";
4
- export declare const VehicleRigidBody: import("react").ForwardRefExoticComponent<{
4
+ export declare const RigidBodyRef: import("react").ForwardRefExoticComponent<{
5
5
  props: controllerInnerType;
6
6
  children: ReactNode;
7
7
  } & import("react").RefAttributes<RapierRigidBody>>;
@@ -10,10 +10,9 @@ var __assign = (this && this.__assign) || function () {
10
10
  return __assign.apply(this, arguments);
11
11
  };
12
12
  import { jsx as _jsx } from "react/jsx-runtime";
13
- import { forwardRef, useContext } from "react";
14
- import { GaesupWorldContext } from "../../../world/context";
15
- export var VehicleGroup = forwardRef(function (_a, ref) {
13
+ import { RigidBody } from "@react-three/rapier";
14
+ import { forwardRef } from "react";
15
+ export var RigidBodyRef = forwardRef(function (_a, ref) {
16
16
  var props = _a.props, children = _a.children;
17
- var mode = useContext(GaesupWorldContext).mode;
18
- return (_jsx("group", __assign({ ref: ref, userData: { intangible: true } }, props.vehicle, { visible: mode.type === "vehicle", children: children })));
17
+ return (_jsx(RigidBody, __assign({ colliders: false, ref: ref }, props.rigidBodyProps, { children: children })));
19
18
  });
@@ -0,0 +1,12 @@
1
+ import { ReactNode, Ref } from "react";
2
+ import * as THREE from "three";
3
+ import { controllerInnerType, refsType } from "../../../controller/type";
4
+ import { GLTFResult } from "../../type";
5
+ export declare function WrapperRef({ children, outerChildren, props, refs, gltf, animationRef, }: {
6
+ children: ReactNode;
7
+ outerChildren?: ReactNode;
8
+ props: controllerInnerType;
9
+ refs: refsType;
10
+ gltf: GLTFResult;
11
+ animationRef?: Ref<THREE.Object3D<THREE.Object3DEventMap>>;
12
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,9 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { InnerGroupRef } from "../common/InnerGroupRef";
3
+ import { OuterGroupRef } from "../common/OuterGroupRef";
4
+ import { SlopeRayRef } from "../common/slopeRayRef";
5
+ import { RigidBodyRef } from "./RigidbodyRef";
6
+ export function WrapperRef(_a) {
7
+ var children = _a.children, outerChildren = _a.outerChildren, props = _a.props, refs = _a.refs, gltf = _a.gltf, animationRef = _a.animationRef;
8
+ return (_jsxs(OuterGroupRef, { ref: refs.outerGroupRef, props: props, children: [_jsxs(RigidBodyRef, { ref: refs.rigidBodyRef, props: props, children: [_jsx(SlopeRayRef, { slopeRay: props.slopeRay, groundRay: props.groundRay, ref: refs.slopeRayOriginRef }), children, props.children, _jsx(InnerGroupRef, { props: props, gltf: gltf, ref: refs.innerGroupRef, animationRef: animationRef })] }), outerChildren] }));
9
+ }
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import { groundRayType, slopeRayType } from "../../../controller/type";
3
- export declare const CharacterSlopeRay: import("react").ForwardRefExoticComponent<{
3
+ export declare const SlopeRayRef: import("react").ForwardRefExoticComponent<{
4
4
  groundRay: groundRayType;
5
5
  slopeRay: slopeRayType;
6
6
  } & import("react").RefAttributes<import("three").Mesh<import("three").BufferGeometry<import("three").NormalBufferAttributes>, import("three").Material | import("three").Material[], import("three").Object3DEventMap>>>;
@@ -1,10 +1,10 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { forwardRef } from "react";
3
- export var CharacterSlopeRay = forwardRef(function (_a, ref) {
3
+ export var SlopeRayRef = forwardRef(function (_a, ref) {
4
4
  var groundRay = _a.groundRay, slopeRay = _a.slopeRay;
5
5
  return (_jsx("mesh", { position: [
6
6
  groundRay.offset.x,
7
7
  groundRay.offset.y,
8
8
  groundRay.offset.z + slopeRay.offset.z,
9
- ], ref: ref, visible: false, userData: { intangible: true }, children: _jsx("boxGeometry", { args: [0.15, 0.15, 0.15] }) }));
9
+ ], ref: ref, visible: false, children: _jsx("boxGeometry", { args: [0.15, 0.15, 0.15] }) }));
10
10
  });
@@ -0,0 +1,12 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useContext } from "react";
3
+ import { GaesupWorldContext } from "../../../world/context";
4
+ import { InnerGroupRef } from "../common/InnerGroupRef";
5
+ import { WrapperRef } from "../common/WrapperRef";
6
+ import { VehicleCollider } from "./collider";
7
+ import { Wheels } from "./wheels";
8
+ export function VehicleRef(_a) {
9
+ var props = _a.props, refs = _a.refs;
10
+ var _b = useContext(GaesupWorldContext), url = _b.url, characterGltf = _b.characterGltf, vehicleGltf = _b.vehicleGltf;
11
+ return (_jsxs(WrapperRef, { props: props, refs: refs, gltf: vehicleGltf, outerChildren: url.wheelUrl ? _jsx(Wheels, { props: props }) : _jsx(_Fragment, {}), children: [props.isRider && (_jsx(InnerGroupRef, { props: props, gltf: characterGltf, ref: refs.characterInnerRef })), _jsx(VehicleCollider, {})] }));
12
+ }
@@ -1,6 +1,7 @@
1
1
  import { RapierRigidBody } from "@react-three/rapier";
2
2
  import { RefObject } from "react";
3
3
  export type wheelRegidBodyType = {
4
+ index: number;
4
5
  wheelPosition: [number, number, number];
5
6
  bodyRef: RefObject<RapierRigidBody>;
6
7
  wheel: RefObject<RapierRigidBody>;
@@ -1,12 +1,13 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Gltf } from "@react-three/drei";
3
3
  import { CylinderCollider, RigidBody, useRevoluteJoint, } from "@react-three/rapier";
4
- import { forwardRef, useContext } from "react";
4
+ import { forwardRef, useContext, useRef } from "react";
5
5
  import { GaesupWorldContext } from "../../../world/context";
6
6
  export var WheelRegidBodyRef = forwardRef(function (_a, ref) {
7
- var wheelPosition = _a.wheelPosition, bodyRef = _a.bodyRef, wheel = _a.wheel, bodyAnchor = _a.bodyAnchor, wheelAnchor = _a.wheelAnchor, rotationAxis = _a.rotationAxis;
7
+ var index = _a.index, wheelPosition = _a.wheelPosition, bodyRef = _a.bodyRef, wheel = _a.wheel, bodyAnchor = _a.bodyAnchor, wheelAnchor = _a.wheelAnchor, rotationAxis = _a.rotationAxis;
8
8
  var _b = useContext(GaesupWorldContext), collider = _b.vehicleCollider, url = _b.url;
9
9
  var wheelSizeX = collider.wheelSizeX, wheelSizeY = collider.wheelSizeY;
10
10
  useRevoluteJoint(bodyRef, wheel, [bodyAnchor, wheelAnchor, rotationAxis]);
11
- return (_jsxs(RigidBody, { position: wheelPosition, colliders: false, ref: ref, children: [_jsx(CylinderCollider, { args: [wheelSizeX / 2, wheelSizeY / 2], rotation: [0, 0, Math.PI / 2] }), _jsx(Gltf, { src: url.wheelUrl })] }));
11
+ var colliderRef = useRef(null);
12
+ return (_jsxs(RigidBody, { position: wheelPosition, colliders: false, ref: ref, userData: { intangible: true }, children: [_jsx(CylinderCollider, { args: [wheelSizeX / 2, wheelSizeY / 2], rotation: [0, 0, Math.PI / 2], ref: colliderRef }), _jsx(Gltf, { src: url.wheelUrl })] }));
12
13
  });
@@ -1,4 +1,7 @@
1
1
  import { controllerInnerType } from "../../../controller/type";
2
+ export type useSetWheelType = {
3
+ wheelPositions: [number, number, number][];
4
+ };
2
5
  export declare function Wheels({ props }: {
3
6
  props: controllerInnerType;
4
7
  }): import("react/jsx-runtime").JSX.Element;
@@ -18,5 +18,5 @@ export function Wheels(_a) {
18
18
  [X, 0, -Z],
19
19
  ];
20
20
  var wheelRefs = useRef(wheelPositions.map(function () { return createRef(); }));
21
- return (_jsx(_Fragment, { children: wheelPositions.map(function (wheelPosition, index) { return (_jsx(WheelRegidBodyRef, { ref: wheelRefs.current[index], wheelPosition: wheelPosition, bodyRef: rigidBodyRef, wheel: wheelRefs.current[index], bodyAnchor: wheelPosition, wheelAnchor: [0, 0, 0], rotationAxis: [1, 0, 0] }, index)); }) }));
21
+ return (_jsx(_Fragment, { children: wheelPositions.map(function (wheelPosition, index) { return (_jsx(WheelRegidBodyRef, { index: index, ref: wheelRefs.current[index], wheelPosition: wheelPosition, bodyRef: rigidBodyRef, wheel: wheelRefs.current[index], bodyAnchor: wheelPosition, wheelAnchor: [0, 0, 0], rotationAxis: [1, 0, 0] }, index)); }) }));
22
22
  }
@@ -1,4 +1,6 @@
1
1
  import { controllerInnerType, refsType } from "../controller/type";
2
+ import { gaesupPassivePropsType } from "../hooks/useGaesupController";
3
+ export declare function GaesupPassiveComponent(props: gaesupPassivePropsType): import("react/jsx-runtime").JSX.Element;
2
4
  export declare function GaesupComponent({ props, refs, }: {
3
5
  props: controllerInnerType;
4
6
  refs: refsType;
@@ -1,11 +1,20 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useContext } from "react";
3
+ import calculation from "../physics";
3
4
  import { GaesupWorldContext } from "../world/context";
4
- import { Airplane } from "./mode/Airplane";
5
- import { Character } from "./mode/Character";
6
- import { Vehicle } from "./mode/Vehicle";
5
+ import { AirplaneRef } from "./active/airplane";
6
+ import { CharacterRef } from "./active/character";
7
+ import { VehicleRef } from "./active/vehicle";
8
+ import { PassiveAirplane } from "./passive/airplane";
9
+ import { PassiveCharacter } from "./passive/character";
10
+ import { PassiveVehicle } from "./passive/vehicle";
11
+ export function GaesupPassiveComponent(props) {
12
+ var mode = props.mode;
13
+ return (_jsxs(_Fragment, { children: [mode.type === "character" && _jsx(PassiveCharacter, { props: props }), mode.type === "vehicle" && _jsx(PassiveVehicle, { props: props }), mode.type === "airplane" && _jsx(PassiveAirplane, { props: props })] }));
14
+ }
7
15
  export function GaesupComponent(_a) {
8
16
  var props = _a.props, refs = _a.refs;
9
17
  var mode = useContext(GaesupWorldContext).mode;
10
- return (_jsxs(_Fragment, { children: [mode.type === "character" && _jsx(Character, { props: props, refs: refs }), mode.type === "vehicle" && _jsx(Vehicle, { props: props, refs: refs }), mode.type === "airplane" && _jsx(Airplane, { props: props, refs: refs })] }));
18
+ calculation(props);
19
+ return (_jsxs(_Fragment, { children: [mode.type === "character" && _jsx(CharacterRef, { props: props, refs: refs }), mode.type === "vehicle" && _jsx(VehicleRef, { props: props, refs: refs }), mode.type === "airplane" && _jsx(AirplaneRef, { props: props, refs: refs })] }));
11
20
  }
@@ -0,0 +1,6 @@
1
+ /// <reference types="react" />
2
+ import { Collider } from "@dimforge/rapier3d-compat";
3
+ import { airplaneColliderType } from "../../../world/context/type";
4
+ export declare const AirplaneCollider: import("react").ForwardRefExoticComponent<{
5
+ collider: airplaneColliderType;
6
+ } & import("react").RefAttributes<Collider>>;