gaesup-world 0.1.3 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (141) hide show
  1. package/README.md +220 -228
  2. package/dist/gaesup/animation/actions.d.ts +29 -13
  3. package/dist/gaesup/animation/actions.js +33 -60
  4. package/dist/gaesup/camera/index.js +1 -2
  5. package/dist/gaesup/component/active/airplane/index.d.ts +9 -3
  6. package/dist/gaesup/component/active/airplane/index.js +3 -7
  7. package/dist/gaesup/component/active/character/index.d.ts +3 -1
  8. package/dist/gaesup/component/active/character/index.js +29 -11
  9. package/dist/gaesup/component/active/vehicle/index.d.ts +10 -3
  10. package/dist/gaesup/component/active/vehicle/index.js +29 -9
  11. package/dist/gaesup/component/index.d.ts +3 -1
  12. package/dist/gaesup/component/index.js +9 -3
  13. package/dist/gaesup/component/inner/airplane/index.d.ts +2 -0
  14. package/dist/gaesup/component/inner/airplane/index.js +16 -0
  15. package/dist/gaesup/component/inner/character/index.d.ts +25 -0
  16. package/dist/gaesup/component/inner/character/index.js +28 -0
  17. package/dist/gaesup/component/{passive → inner}/common/InnerGroupRef.d.ts +2 -0
  18. package/dist/gaesup/component/{passive → inner}/common/InnerGroupRef.js +12 -10
  19. package/dist/gaesup/component/{passive → inner}/common/RigidbodyRef.d.ts +4 -0
  20. package/dist/gaesup/component/inner/common/RigidbodyRef.js +7 -0
  21. package/dist/gaesup/component/inner/common/setGroundRay.d.ts +9 -0
  22. package/dist/gaesup/component/inner/common/setGroundRay.js +14 -0
  23. package/dist/gaesup/component/inner/common/type.d.ts +20 -0
  24. package/dist/gaesup/component/inner/rider/index.d.ts +11 -0
  25. package/dist/gaesup/component/inner/rider/index.js +31 -0
  26. package/dist/gaesup/component/inner/vehicle/collider.d.ts +10 -0
  27. package/dist/gaesup/component/inner/vehicle/collider.js +19 -0
  28. package/dist/gaesup/component/inner/vehicle/index.d.ts +2 -0
  29. package/dist/gaesup/component/inner/vehicle/index.js +17 -0
  30. package/dist/gaesup/component/inner/vehicle/wheels.d.ts +7 -0
  31. package/dist/gaesup/component/inner/vehicle/wheels.js +64 -0
  32. package/dist/gaesup/component/passive/airplane/index.d.ts +12 -1
  33. package/dist/gaesup/component/passive/airplane/index.js +6 -9
  34. package/dist/gaesup/component/passive/character/index.d.ts +9 -1
  35. package/dist/gaesup/component/passive/character/index.js +16 -9
  36. package/dist/gaesup/component/passive/type.d.ts +1 -11
  37. package/dist/gaesup/component/passive/vehicle/index.d.ts +12 -1
  38. package/dist/gaesup/component/passive/vehicle/index.js +6 -25
  39. package/dist/gaesup/controller/context/index.d.ts +7 -3
  40. package/dist/gaesup/controller/context/index.js +7 -3
  41. package/dist/gaesup/controller/context/reducer.d.ts +1 -1
  42. package/dist/gaesup/controller/index.js +5 -8
  43. package/dist/gaesup/controller/initialize/callback/index.d.ts +1 -1
  44. package/dist/gaesup/controller/initialize/callback/index.js +61 -54
  45. package/dist/gaesup/controller/initialize/index.d.ts +1 -2
  46. package/dist/gaesup/controller/initialize/index.js +1 -14
  47. package/dist/gaesup/controller/type.d.ts +3 -6
  48. package/dist/gaesup/gaesupProps/index.js +1 -1
  49. package/dist/gaesup/hooks/useGaesupAnimation/index.d.ts +3 -1
  50. package/dist/gaesup/hooks/useGaesupAnimation/index.js +17 -16
  51. package/dist/gaesup/hooks/useGaesupController/index.d.ts +2 -5
  52. package/dist/gaesup/hooks/useGaesupController/index.js +4 -5
  53. package/dist/gaesup/hooks/useGaesupGltf/index.d.ts +25 -0
  54. package/dist/gaesup/hooks/useGaesupGltf/index.js +73 -0
  55. package/dist/gaesup/hooks/useRideable/index.js +36 -35
  56. package/dist/gaesup/physics/airplane/direction.d.ts +1 -1
  57. package/dist/gaesup/physics/airplane/direction.js +3 -1
  58. package/dist/gaesup/physics/airplane/gravity.js +1 -1
  59. package/dist/gaesup/physics/airplane/landing.js +1 -1
  60. package/dist/gaesup/physics/check/ground.js +3 -3
  61. package/dist/gaesup/physics/check/index.js +0 -2
  62. package/dist/gaesup/physics/check/riding.js +3 -3
  63. package/dist/gaesup/physics/index.js +8 -6
  64. package/dist/gaesup/physics/type.d.ts +4 -1
  65. package/dist/gaesup/physics/vehicle/impulse.d.ts +15 -1
  66. package/dist/gaesup/physics/vehicle/impulse.js +32 -12
  67. package/dist/gaesup/physics/vehicle/innerCalc.js +1 -1
  68. package/dist/gaesup/physics/vehicle/landing.js +1 -1
  69. package/dist/gaesup/tools/joyStick/index.d.ts +1 -1
  70. package/dist/gaesup/tools/keyBoardToolTip/index.js +3 -3
  71. package/dist/gaesup/tools/rideable/index.js +5 -6
  72. package/dist/gaesup/tools/zoomButton/index.js +5 -3
  73. package/dist/gaesup/world/context/index.js +27 -62
  74. package/dist/gaesup/world/context/reducer.d.ts +7 -12
  75. package/dist/gaesup/world/context/type.d.ts +36 -49
  76. package/dist/gaesup/world/debug/index.d.ts +6 -2
  77. package/dist/gaesup/world/initalize/index.d.ts +7 -12
  78. package/dist/gaesup/world/initalize/index.js +8 -15
  79. package/dist/gaesup/world/type.d.ts +3 -8
  80. package/dist/index.d.ts +0 -1
  81. package/dist/index.js +0 -1
  82. package/package.json +1 -1
  83. package/dist/gaesup/animation/index.d.ts +0 -1
  84. package/dist/gaesup/animation/index.js +0 -1
  85. package/dist/gaesup/animation/passiveActions.d.ts +0 -9
  86. package/dist/gaesup/animation/passiveActions.js +0 -16
  87. package/dist/gaesup/component/active/airplane/collider.d.ts +0 -6
  88. package/dist/gaesup/component/active/airplane/collider.js +0 -22
  89. package/dist/gaesup/component/active/character/collider.d.ts +0 -6
  90. package/dist/gaesup/component/active/character/collider.js +0 -24
  91. package/dist/gaesup/component/active/common/InnerGroupRef.d.ts +0 -10
  92. package/dist/gaesup/component/active/common/InnerGroupRef.js +0 -35
  93. package/dist/gaesup/component/active/common/OuterGroupRef.d.ts +0 -6
  94. package/dist/gaesup/component/active/common/OuterGroupRef.js +0 -17
  95. package/dist/gaesup/component/active/common/RiderGroupRef.d.ts +0 -7
  96. package/dist/gaesup/component/active/common/RiderGroupRef.js +0 -32
  97. package/dist/gaesup/component/active/common/RigidbodyRef.d.ts +0 -11
  98. package/dist/gaesup/component/active/common/RigidbodyRef.js +0 -22
  99. package/dist/gaesup/component/active/common/WrapperRef.d.ts +0 -13
  100. package/dist/gaesup/component/active/common/WrapperRef.js +0 -9
  101. package/dist/gaesup/component/active/common/slopeRayRef.d.ts +0 -6
  102. package/dist/gaesup/component/active/common/slopeRayRef.js +0 -10
  103. package/dist/gaesup/component/active/vehicle/collider.d.ts +0 -3
  104. package/dist/gaesup/component/active/vehicle/collider.js +0 -9
  105. package/dist/gaesup/component/active/vehicle/wheel.d.ts +0 -12
  106. package/dist/gaesup/component/active/vehicle/wheel.js +0 -13
  107. package/dist/gaesup/component/active/vehicle/wheels.d.ts +0 -7
  108. package/dist/gaesup/component/active/vehicle/wheels.js +0 -20
  109. package/dist/gaesup/component/passive/airplane/collider.d.ts +0 -5
  110. package/dist/gaesup/component/passive/airplane/collider.js +0 -7
  111. package/dist/gaesup/component/passive/airplane/type.d.ts +0 -12
  112. package/dist/gaesup/component/passive/character/collider.d.ts +0 -6
  113. package/dist/gaesup/component/passive/character/collider.js +0 -7
  114. package/dist/gaesup/component/passive/character/type.d.ts +0 -27
  115. package/dist/gaesup/component/passive/character/type.js +0 -1
  116. package/dist/gaesup/component/passive/common/RigidbodyRef.js +0 -10
  117. package/dist/gaesup/component/passive/vehicle/type.d.ts +0 -21
  118. package/dist/gaesup/component/passive/vehicle/type.js +0 -1
  119. package/dist/gaesup/component/passive/vehicle/wheel.d.ts +0 -15
  120. package/dist/gaesup/component/passive/vehicle/wheel.js +0 -16
  121. package/dist/gaesup/component/passive/vehicle/wheels.d.ts +0 -11
  122. package/dist/gaesup/component/passive/vehicle/wheels.js +0 -25
  123. package/dist/gaesup/physics/check/slope.d.ts +0 -2
  124. package/dist/gaesup/physics/check/slope.js +0 -30
  125. package/dist/gaesup/utils/gltf.d.ts +0 -7
  126. package/dist/gaesup/utils/gltf.js +0 -10
  127. package/dist/gaesup/world/initalize/collider/airplane.d.ts +0 -2
  128. package/dist/gaesup/world/initalize/collider/airplane.js +0 -25
  129. package/dist/gaesup/world/initalize/collider/character.d.ts +0 -2
  130. package/dist/gaesup/world/initalize/collider/character.js +0 -27
  131. package/dist/gaesup/world/initalize/collider/gltf.d.ts +0 -14
  132. package/dist/gaesup/world/initalize/collider/gltf.js +0 -54
  133. package/dist/gaesup/world/initalize/collider/index.d.ts +0 -2
  134. package/dist/gaesup/world/initalize/collider/index.js +0 -17
  135. package/dist/gaesup/world/initalize/collider/vehicle.d.ts +0 -2
  136. package/dist/gaesup/world/initalize/collider/vehicle.js +0 -55
  137. package/dist/gaesup/world/initalize/type.d.ts +0 -13
  138. package/dist/gaesup/world/initalize/type.js +0 -1
  139. /package/dist/gaesup/component/{passive → inner}/common/OuterGroupRef.d.ts +0 -0
  140. /package/dist/gaesup/component/{passive → inner}/common/OuterGroupRef.js +0 -0
  141. /package/dist/gaesup/component/{passive/airplane → inner/common}/type.js +0 -0
@@ -45,7 +45,7 @@ import { GaesupWorldContext } from "../../world/context/index.js";
45
45
  import "./style.css";
46
46
  export function Rideable(props) {
47
47
  var _this = this;
48
- var _a = useContext(GaesupWorldContext), states = _a.states, rideable = _a.rideable, vehicleCollider = _a.vehicleCollider, airplaneCollider = _a.airplaneCollider;
48
+ var _a = useContext(GaesupWorldContext), states = _a.states, rideable = _a.rideable;
49
49
  var _b = useRideable(), initRideable = _b.initRideable, getRideable = _b.getRideable, ride = _b.ride, landing = _b.landing;
50
50
  var current = getRideable(props.objectkey);
51
51
  useEffect(function () {
@@ -70,11 +70,10 @@ export function Rideable(props) {
70
70
  }); };
71
71
  return (_jsx(_Fragment, { children: current &&
72
72
  rideable[props.objectkey] &&
73
- rideable[props.objectkey].visible && (_jsxs("group", { userData: { intangible: true }, children: [props.objectType === "vehicle" && (_jsx(PassiveVehicle, { position: current.position || V3(0, 0, 0), euler: current.rotation || euler(), vehicleSize: current.vehicleSize ||
74
- V3(vehicleCollider.vehicleSizeX, vehicleCollider.vehicleSizeY, vehicleCollider.vehicleSizeZ), wheelSize: current.wheelSize ||
75
- V3(vehicleCollider.wheelSizeX, vehicleCollider.wheelSizeY, vehicleCollider.wheelSizeZ), currentAnimation: "idle", url: {
73
+ rideable[props.objectkey].visible && (_jsxs("group", { userData: { intangible: true }, children: [props.objectType === "vehicle" && (_jsx(PassiveVehicle, { position: current.position || V3(0, 0, 0), euler: current.rotation || euler(), currentAnimation: "idle", offset: props.offset, urls: {
76
74
  vehicleUrl: props.url,
77
75
  wheelUrl: props.wheelUrl,
78
- }, onCollisionEnter: onCollisionEnter })), props.objectType === "airplane" && (_jsx(PassiveAirplane, { position: current.position || V3(0, 0, 0), euler: current.rotation || euler(), airplaneSize: current.airplaneSize ||
79
- V3(airplaneCollider.airplaneSizeX, airplaneCollider.airplaneSizeY, airplaneCollider.airplaneSizeZ), currentAnimation: "idle", airplaneUrl: props.url, onCollisionEnter: onCollisionEnter }))] })) }));
76
+ }, onCollisionEnter: onCollisionEnter })), props.objectType === "airplane" && (_jsx(PassiveAirplane, { position: current.position || V3(0, 0, 0), euler: current.rotation || euler(), currentAnimation: "idle", offset: props.offset, urls: {
77
+ airplaneUrl: props.url,
78
+ }, onCollisionEnter: onCollisionEnter }))] })) }));
80
79
  }
@@ -53,7 +53,7 @@ import { GaesupWorldContext, GaesupWorldDispatchContext, } from "../../world/con
53
53
  import "./style.css";
54
54
  export function useZoom() {
55
55
  var _this = this;
56
- var _a = useContext(GaesupWorldContext), moveTo = _a.moveTo, activeState = _a.activeState, cameraOption = _a.cameraOption, mode = _a.mode;
56
+ var _a = useContext(GaesupWorldContext), moveTo = _a.moveTo, activeState = _a.activeState, cameraOption = _a.cameraOption, mode = _a.mode, block = _a.block;
57
57
  var dispatch = useContext(GaesupWorldDispatchContext);
58
58
  var _b = useState(true), isZoom = _b[0], setIsZoom = _b[1];
59
59
  var closeCamera = function (position) { return __awaiter(_this, void 0, void 0, function () {
@@ -61,10 +61,11 @@ export function useZoom() {
61
61
  cameraOption.XDistance = position.x;
62
62
  cameraOption.YDistance = position.y;
63
63
  cameraOption.ZDistance = position.z;
64
+ block.camera = true;
64
65
  dispatch({
65
66
  type: "update",
66
67
  payload: {
67
- cameraBlock: true,
68
+ block: __assign({}, block),
68
69
  cameraOption: __assign({}, cameraOption),
69
70
  },
70
71
  });
@@ -73,10 +74,11 @@ export function useZoom() {
73
74
  }); };
74
75
  var openCamera = function () { return __awaiter(_this, void 0, void 0, function () {
75
76
  return __generator(this, function (_a) {
77
+ block.camera = false;
76
78
  dispatch({
77
79
  type: "update",
78
80
  payload: {
79
- cameraBlock: false,
81
+ block: __assign({}, block),
80
82
  },
81
83
  });
82
84
  return [2 /*return*/];
@@ -13,47 +13,15 @@ export var gaesupWorldDefault = {
13
13
  dir: vec3(),
14
14
  direction: vec3(),
15
15
  },
16
- characterCollider: {
17
- halfHeight: 0.35,
18
- height: 0.7,
19
- radius: 0.3,
20
- diameter: 0.6,
21
- riderOffsetX: 0,
22
- riderOffsetY: 0,
23
- riderOffsetZ: 0,
24
- },
25
- vehicleCollider: {
26
- wheelSizeX: 0.5,
27
- wheelSizeY: 0.5,
28
- wheelSizeZ: 0.5,
29
- vehicleSizeX: 1,
30
- vehicleSizeY: 1,
31
- vehicleSizeZ: 1,
32
- vehicleX: 0.5,
33
- vehicleY: 0.5,
34
- vehicleZ: 0.5,
35
- },
36
- airplaneCollider: {
37
- airplaneSizeX: 1,
38
- airplaneSizeY: 1,
39
- airplaneSizeZ: 1,
40
- airplaneX: 0.5,
41
- airplaneY: 0.5,
42
- airplaneZ: 0.5,
43
- gravity: 0.2,
44
- },
45
16
  mode: {},
46
- url: {
17
+ urls: {
47
18
  characterUrl: null,
48
19
  vehicleUrl: null,
49
20
  airplaneUrl: null,
50
21
  wheelUrl: null,
51
22
  },
52
- characterGltf: null,
53
- vehicleGltf: null,
54
- wheelGltf: null,
55
- airplaneGltf: null,
56
23
  states: {
24
+ rideableId: null,
57
25
  isMoving: false,
58
26
  isNotMoving: false,
59
27
  isOnTheGround: false,
@@ -61,7 +29,7 @@ export var gaesupWorldDefault = {
61
29
  isRotated: false,
62
30
  isRunning: false,
63
31
  isJumping: false,
64
- isRiding: false,
32
+ enableRiding: false,
65
33
  isRiderOn: false,
66
34
  isLanding: false,
67
35
  isPush: {
@@ -99,25 +67,22 @@ export var gaesupWorldDefault = {
99
67
  rightward: false,
100
68
  },
101
69
  refs: null,
102
- animations: {
103
- current: "idle",
104
- animationNames: {
105
- idle: "idle",
106
- walk: "walk",
107
- run: "run",
108
- accel: "accel",
109
- break: "break",
110
- ride: "ride",
111
- jump: "jump",
112
- jumpIdle: "jumpIdle",
113
- jumpLand: "jumpLand",
114
- fall: "fall",
115
- land: "land",
116
- sit: "sit",
70
+ animationState: {
71
+ character: {
72
+ current: "idle",
73
+ default: "idle",
74
+ store: {},
75
+ },
76
+ vehicle: {
77
+ current: "idle",
78
+ default: "idle",
79
+ store: {},
80
+ },
81
+ airplane: {
82
+ current: "idle",
83
+ default: "idle",
84
+ store: {},
117
85
  },
118
- keyControl: {},
119
- store: {},
120
- default: "idle",
121
86
  },
122
87
  keyBoardMap: [
123
88
  { name: "forward", keys: ["ArrowUp", "KeyW"] },
@@ -130,23 +95,23 @@ export var gaesupWorldDefault = {
130
95
  ],
131
96
  cameraOption: {
132
97
  offset: V3(-10, -10, -10),
133
- initDistance: -5,
134
98
  maxDistance: -7,
135
- minDistance: -0.7,
136
- initDir: 0,
137
- collisionOff: 0.7,
138
99
  distance: -1,
139
- camFollow: 11,
140
- XZDistance: 20,
141
100
  XDistance: 20,
142
101
  YDistance: 10,
143
102
  ZDistance: 20,
144
103
  },
145
104
  moveTo: null,
146
- cameraBlock: false,
147
- controlBlock: false,
148
- scrollBlock: true,
149
105
  rideable: {},
106
+ sizes: {},
107
+ block: {
108
+ camera: false,
109
+ control: false,
110
+ scroll: true,
111
+ },
112
+ callback: {
113
+ moveTo: null,
114
+ },
150
115
  };
151
116
  export var GaesupWorldContext = createContext(null);
152
117
  export var GaesupWorldDispatchContext = createContext(null);
@@ -4,15 +4,8 @@ export declare function gaesupWorldReducer(props: gaesupWorldContextType, action
4
4
  payload?: Partial<gaesupWorldContextType>;
5
5
  }): {
6
6
  activeState: import("./type").activeStateType;
7
- characterCollider: import("./type").characterColliderType;
8
- vehicleCollider: import("./type").vehicleColliderType;
9
- airplaneCollider: import("./type").airplaneColliderType;
10
7
  mode: import("./type").modeType;
11
- url: import("./type").urlType;
12
- characterGltf: import("../../component/type").GLTFResult;
13
- vehicleGltf: import("../../component/type").GLTFResult;
14
- wheelGltf: import("../../component/type").GLTFResult;
15
- airplaneGltf: import("../../component/type").GLTFResult;
8
+ urls: import("./type").urlsType;
16
9
  states: import("./type").statesType;
17
10
  debug: boolean;
18
11
  minimap: import("../../tools/miniMap/type").minimapInnerType;
@@ -21,14 +14,16 @@ export declare function gaesupWorldReducer(props: gaesupWorldContextType, action
21
14
  [x: string]: boolean;
22
15
  };
23
16
  refs: import("../../controller/type").refsType;
24
- animations: import("./type").animationPropType;
17
+ animationState: import("./type").animationStateType;
25
18
  keyBoardMap: import("../../tools/keyBoardToolTip/type").keyboardMapType;
26
19
  cameraOption: import("./type").cameraOptionType;
27
20
  moveTo: (position: import("three").Vector3, target: import("three").Vector3) => Promise<void>;
28
- cameraBlock: boolean;
29
- controlBlock: boolean;
30
- scrollBlock: boolean;
31
21
  rideable: {
32
22
  [key: string]: import("./type").rideableType;
33
23
  };
24
+ sizes: import("./type").sizesType;
25
+ block: import("./type").blockType;
26
+ callback: {
27
+ moveTo: (position: import("three").Vector3, target: import("three").Vector3) => Promise<void>;
28
+ };
34
29
  };
@@ -1,25 +1,18 @@
1
1
  import { CSSProperties } from "react";
2
- import { GLTFResult } from "../../component/type";
3
2
  import { actionsType, refsType } from "../../controller/type";
4
3
  import { joyStickInnerType } from "../../tools/joyStick/type";
5
4
  import { keyboardMapType } from "../../tools/keyBoardToolTip/type";
6
5
  import { minimapInnerType } from "../../tools/miniMap/type";
7
6
  import { dispatchType } from "../../utils/type";
8
7
  export type gaesupCameraOptionDebugType = {
9
- initDistance?: number;
10
8
  maxDistance?: number;
11
- minDistance?: number;
12
- initDir?: number;
13
9
  distance?: number;
14
- camFollow?: number;
15
- XZDistance?: number;
16
10
  XDistance?: number;
17
11
  YDistance?: number;
18
12
  ZDistance?: number;
19
13
  };
20
14
  export type cameraOptionType = {
21
15
  offset?: THREE.Vector3;
22
- collisionOff?: number;
23
16
  } & gaesupCameraOptionDebugType;
24
17
  export type controlType = {
25
18
  forward: boolean;
@@ -38,6 +31,7 @@ export type portalType = {
38
31
  };
39
32
  export type portalsType = portalType[];
40
33
  export type statesType = {
34
+ rideableId?: string;
41
35
  isMoving: boolean;
42
36
  isNotMoving: boolean;
43
37
  isOnTheGround: boolean;
@@ -45,12 +39,12 @@ export type statesType = {
45
39
  isRotated: boolean;
46
40
  isRunning: boolean;
47
41
  isJumping: boolean;
48
- isRiding: boolean;
42
+ enableRiding: boolean;
49
43
  isRiderOn: boolean;
50
44
  isPush: controlType;
51
45
  isLanding: boolean;
52
46
  };
53
- export type urlType = {
47
+ export type urlsType = {
54
48
  characterUrl?: string;
55
49
  vehicleUrl?: string;
56
50
  airplaneUrl?: string;
@@ -72,34 +66,14 @@ export type animationPropType = {
72
66
  store: {};
73
67
  default: string;
74
68
  };
75
- export type characterColliderType = {
76
- halfHeight?: number;
77
- height?: number;
78
- radius?: number;
79
- diameter?: number;
80
- riderOffsetX?: number;
81
- riderOffsetY?: number;
82
- riderOffsetZ?: number;
83
- };
84
- export type vehicleColliderType = {
85
- wheelSizeX?: number;
86
- wheelSizeY?: number;
87
- wheelSizeZ?: number;
88
- vehicleSizeX?: number;
89
- vehicleSizeY?: number;
90
- vehicleSizeZ?: number;
91
- vehicleX?: number;
92
- vehicleY?: number;
93
- vehicleZ?: number;
94
- };
95
- export type airplaneColliderType = {
96
- airplaneSizeX?: number;
97
- airplaneSizeY?: number;
98
- airplaneSizeZ?: number;
99
- airplaneX?: number;
100
- airplaneY?: number;
101
- airplaneZ?: number;
102
- gravity?: number;
69
+ export type animationStatePropType = {
70
+ current: string;
71
+ animationNames?: actionsType;
72
+ keyControl?: {
73
+ [key: string]: boolean;
74
+ };
75
+ store: {};
76
+ default: string;
103
77
  };
104
78
  export type modeType = {
105
79
  type?: "character" | "vehicle" | "airplane";
@@ -121,6 +95,16 @@ export type wheelStateType = {
121
95
  position: THREE.Vector3;
122
96
  rotation: THREE.Euler;
123
97
  };
98
+ export type blockType = {
99
+ camera: boolean;
100
+ control: boolean;
101
+ scroll: boolean;
102
+ };
103
+ export type sizeType = {
104
+ x: number;
105
+ y: number;
106
+ z: number;
107
+ };
124
108
  export type wheelsStateType = {
125
109
  0?: wheelStateType;
126
110
  1?: wheelStateType;
@@ -136,47 +120,50 @@ export type passiveStateType = {
136
120
  export type rideableType = {
137
121
  objectkey: string;
138
122
  objectType?: "vehicle" | "airplane";
123
+ enableRiding?: boolean;
139
124
  isRiderOn?: boolean;
140
125
  url?: string;
141
126
  wheelUrl?: string;
142
127
  position?: THREE.Vector3;
143
128
  rotation?: THREE.Euler;
144
129
  offset?: THREE.Vector3;
130
+ landingOffset?: THREE.Vector3;
145
131
  visible?: boolean;
146
132
  vehicleSize?: THREE.Vector3;
147
133
  wheelSize?: THREE.Vector3;
148
134
  airplaneSize?: THREE.Vector3;
149
135
  };
136
+ export type animationStateType = {
137
+ [key: string]: animationStatePropType;
138
+ };
139
+ export type sizesType = {
140
+ [key: string]: THREE.Vector3;
141
+ };
150
142
  type KeyboardControlsState<T extends string = string> = {
151
143
  [K in T]: boolean;
152
144
  };
153
145
  export type gaesupWorldContextType = {
154
146
  activeState: activeStateType;
155
- characterCollider: characterColliderType;
156
- vehicleCollider: vehicleColliderType;
157
- airplaneCollider: airplaneColliderType;
158
147
  mode: modeType;
159
- url: urlType;
160
- characterGltf: GLTFResult;
161
- vehicleGltf: GLTFResult;
162
- wheelGltf: GLTFResult;
163
- airplaneGltf: GLTFResult;
148
+ urls: urlsType;
164
149
  states: statesType;
165
150
  debug: boolean;
166
151
  minimap: minimapInnerType;
167
152
  joystick: joyStickInnerType;
168
153
  control: KeyboardControlsState<string>;
169
154
  refs: refsType;
170
- animations: animationPropType;
155
+ animationState: animationStateType;
171
156
  keyBoardMap: keyboardMapType;
172
157
  cameraOption: cameraOptionType;
173
158
  moveTo: (position: THREE.Vector3, target: THREE.Vector3) => Promise<void>;
174
- cameraBlock: boolean;
175
- controlBlock: boolean;
176
- scrollBlock: boolean;
177
159
  rideable: {
178
160
  [key: string]: rideableType;
179
161
  };
162
+ sizes: sizesType;
163
+ block: blockType;
164
+ callback: {
165
+ moveTo: (position: THREE.Vector3, target: THREE.Vector3) => Promise<void>;
166
+ };
180
167
  };
181
168
  export type gaesupDisptachType = dispatchType<gaesupWorldContextType>;
182
169
  export {};
@@ -1,2 +1,6 @@
1
- import { innerDebugPropType } from "../initalize/type";
2
- export default function initDebug({ value, dispatch }: innerDebugPropType): void;
1
+ import { dispatchType } from "../../utils/type";
2
+ import { gaesupWorldContextType } from "../context/type";
3
+ export default function initDebug({ value, dispatch, }: {
4
+ value: gaesupWorldContextType;
5
+ dispatch: dispatchType<gaesupWorldContextType>;
6
+ }): void;
@@ -4,15 +4,8 @@ export default function initGaesupWorld(props: gaesupWorldPropsType): {
4
4
  gaesupProps: {
5
5
  value: {
6
6
  activeState: import("../context/type").activeStateType;
7
- characterCollider: import("../context/type").characterColliderType;
8
- vehicleCollider: import("../context/type").vehicleColliderType;
9
- airplaneCollider: import("../context/type").airplaneColliderType;
10
7
  mode: import("../context/type").modeType;
11
- url: import("../context/type").urlType;
12
- characterGltf: import("../../component/type").GLTFResult;
13
- vehicleGltf: import("../../component/type").GLTFResult;
14
- wheelGltf: import("../../component/type").GLTFResult;
15
- airplaneGltf: import("../../component/type").GLTFResult;
8
+ urls: import("../context/type").urlsType;
16
9
  states: import("../context/type").statesType;
17
10
  debug: boolean;
18
11
  minimap: import("../../tools/miniMap/type").minimapInnerType;
@@ -21,16 +14,18 @@ export default function initGaesupWorld(props: gaesupWorldPropsType): {
21
14
  [x: string]: boolean;
22
15
  };
23
16
  refs: import("../../controller/type").refsType;
24
- animations: import("../context/type").animationPropType;
17
+ animationState: import("../context/type").animationStateType;
25
18
  keyBoardMap: import("../../tools/keyBoardToolTip/type").keyboardMapType;
26
19
  cameraOption: import("../context/type").cameraOptionType;
27
20
  moveTo: (position: import("three").Vector3, target: import("three").Vector3) => Promise<void>;
28
- cameraBlock: boolean;
29
- controlBlock: boolean;
30
- scrollBlock: boolean;
31
21
  rideable: {
32
22
  [key: string]: import("../context/type").rideableType;
33
23
  };
24
+ sizes: import("../context/type").sizesType;
25
+ block: import("../context/type").blockType;
26
+ callback: {
27
+ moveTo: (position: import("three").Vector3, target: import("three").Vector3) => Promise<void>;
28
+ };
34
29
  };
35
30
  dispatch: import("react").Dispatch<{
36
31
  type: string;
@@ -14,33 +14,27 @@ import { isDesktop } from "react-device-detect";
14
14
  import { gaesupWorldDefault } from "../../world/context";
15
15
  import { gaesupWorldReducer } from "../../world/context/reducer";
16
16
  import initDebug from "../debug";
17
- import initColider from "./collider";
18
17
  export default function initGaesupWorld(props) {
19
18
  var _a = useReducer(gaesupWorldReducer, {
20
19
  debug: (props.debug && isDesktop) || gaesupWorldDefault.debug,
21
20
  activeState: gaesupWorldDefault.activeState,
22
- characterCollider: Object.assign(gaesupWorldDefault.characterCollider, props.characterCollider || {}),
23
- vehicleCollider: Object.assign(gaesupWorldDefault.vehicleCollider, props.vehicleCollider || {}),
24
- airplaneCollider: Object.assign(gaesupWorldDefault.airplaneCollider, props.airplaneCollider || {}),
25
21
  cameraOption: Object.assign(gaesupWorldDefault.cameraOption, props.cameraOption || {}),
26
22
  mode: Object.assign(gaesupWorldDefault.mode, props.mode || {}),
27
- url: Object.assign(gaesupWorldDefault.url, props.url || {}),
28
- characterGltf: null,
29
- vehicleGltf: null,
30
- wheelGltf: null,
31
- airplaneGltf: null,
23
+ urls: Object.assign(gaesupWorldDefault.urls, props.urls || {}),
32
24
  refs: null,
33
25
  states: gaesupWorldDefault.states,
34
26
  minimap: gaesupWorldDefault.minimap,
35
27
  joystick: gaesupWorldDefault.joystick,
36
28
  control: gaesupWorldDefault.control,
37
- animations: gaesupWorldDefault.animations,
29
+ animationState: gaesupWorldDefault.animationState,
38
30
  keyBoardMap: Object.assign(gaesupWorldDefault.keyBoardMap, props.keyBoardMap || {}),
39
31
  moveTo: null,
40
- cameraBlock: props.cameraBlock || false,
41
- controlBlock: props.controlBlock || false,
42
- scrollBlock: props.scrollBlock || true,
43
32
  rideable: gaesupWorldDefault.rideable,
33
+ block: Object.assign(gaesupWorldDefault.block, props.block || {}),
34
+ sizes: gaesupWorldDefault.sizes,
35
+ callback: {
36
+ moveTo: null,
37
+ },
44
38
  }), value = _a[0], dispatch = _a[1];
45
39
  useEffect(function () {
46
40
  var _a;
@@ -49,7 +43,7 @@ export default function initGaesupWorld(props) {
49
43
  return maps;
50
44
  }, {});
51
45
  var assignedControl = Object.assign(value.control, keyboard);
52
- if (value.scrollBlock)
46
+ if (value.block.scroll)
53
47
  window.addEventListener("touchmove", function (e) { return e.preventDefault(); }, {
54
48
  passive: false,
55
49
  });
@@ -61,7 +55,6 @@ export default function initGaesupWorld(props) {
61
55
  });
62
56
  }, []);
63
57
  var gaesupProps = useMemo(function () { return ({ value: value, dispatch: dispatch }); }, [value, dispatch]);
64
- initColider({ value: value, dispatch: dispatch });
65
58
  initDebug({ value: value, dispatch: dispatch });
66
59
  return {
67
60
  gaesupProps: gaesupProps,
@@ -1,7 +1,7 @@
1
1
  import { ReactNode } from "react";
2
2
  import { keyboardMapType } from "../tools/keyBoardToolTip/type";
3
3
  import { dispatchType } from "../utils/type";
4
- import { airplaneColliderType, cameraOptionType, characterColliderType, gaesupWorldContextType, modeType, urlType, vehicleColliderType } from "./context/type";
4
+ import { blockType, cameraOptionType, gaesupWorldContextType, modeType, urlsType } from "./context/type";
5
5
  export type gaesupWorldInitType = {
6
6
  value: gaesupWorldContextType;
7
7
  dispatch: dispatchType<gaesupWorldContextType>;
@@ -9,16 +9,11 @@ export type gaesupWorldInitType = {
9
9
  export type gaesupWorldPropsType = {
10
10
  children: ReactNode;
11
11
  startPosition?: THREE.Vector3;
12
- url?: urlType;
13
- characterCollider?: characterColliderType;
14
- vehicleCollider?: vehicleColliderType;
15
- airplaneCollider?: airplaneColliderType;
12
+ urls?: urlsType;
16
13
  mode?: modeType;
17
14
  debug?: boolean;
18
15
  keyBoardMap?: keyboardMapType;
19
16
  cameraOption?: cameraOptionType;
20
17
  moveTo?: (position: THREE.Vector3, target: THREE.Vector3) => void;
21
- cameraBlock?: boolean;
22
- controlBlock?: boolean;
23
- scrollBlock?: boolean;
18
+ block?: blockType;
24
19
  };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- export { playActions } from "./gaesup/animation";
2
1
  export * as Camera from "./gaesup/camera";
3
2
  export { GaesupComponent } from "./gaesup/component";
4
3
  export { PassiveAirplane } from "./gaesup/component/passive/airplane";
package/dist/index.js CHANGED
@@ -1,4 +1,3 @@
1
- export { playActions } from "./gaesup/animation";
2
1
  export * as Camera from "./gaesup/camera";
3
2
  export { GaesupComponent } from "./gaesup/component";
4
3
  export { PassiveAirplane } from "./gaesup/component/passive/airplane";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gaesup-world",
3
- "version": "0.1.3",
3
+ "version": "0.2.0",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1 +0,0 @@
1
- export * as playActions from "./actions";
@@ -1 +0,0 @@
1
- export * as playActions from "./actions";
@@ -1,9 +0,0 @@
1
- /// <reference types="react" />
2
- import { AnimationClip } from "three";
3
- export type playPassiveActionsType = {
4
- current: string;
5
- animations: AnimationClip[];
6
- };
7
- export default function playPassiveActions({ current, animations, }: playPassiveActionsType): {
8
- animationRef: import("react").MutableRefObject<import("three").Object3D<import("three").Object3DEventMap>>;
9
- };
@@ -1,16 +0,0 @@
1
- import { useAnimations } from "@react-three/drei";
2
- import { useEffect } from "react";
3
- export default function playPassiveActions(_a) {
4
- var current = _a.current, animations = _a.animations;
5
- var _b = useAnimations(animations), actions = _b.actions, animationRef = _b.ref;
6
- useEffect(function () {
7
- var _a;
8
- var action = (_a = actions[current]) === null || _a === void 0 ? void 0 : _a.reset().fadeIn(0.2).play();
9
- return function () {
10
- action === null || action === void 0 ? void 0 : action.fadeOut(0.2);
11
- };
12
- }, [current]);
13
- return {
14
- animationRef: animationRef,
15
- };
16
- }
@@ -1,6 +0,0 @@
1
- /// <reference types="react" />
2
- import { Collider } from "@dimforge/rapier3d-compat";
3
- import { controllerInnerType } from "../../../controller/type";
4
- export declare const AirplaneCollider: import("react").ForwardRefExoticComponent<{
5
- props: controllerInnerType;
6
- } & import("react").RefAttributes<Collider>>;
@@ -1,22 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { CuboidCollider, useRapier } from "@react-three/rapier";
3
- import { forwardRef, useContext } from "react";
4
- import { getRayHit, useForwardRef } from "../../../utils";
5
- import { GaesupWorldContext } from "../../../world/context";
6
- export var AirplaneCollider = forwardRef(function (_a, ref) {
7
- var _b;
8
- var props = _a.props;
9
- var collider = useContext(GaesupWorldContext).airplaneCollider;
10
- var airplaneSizeX = collider.airplaneSizeX, airplaneSizeY = collider.airplaneSizeY, airplaneSizeZ = collider.airplaneSizeZ;
11
- var colliderRef = useForwardRef(ref);
12
- var rapier = useRapier().rapier;
13
- var groundRay = props.groundRay;
14
- groundRay.length = airplaneSizeY * 5 + 2;
15
- groundRay.rayCast = new rapier.Ray(groundRay.origin, groundRay.dir);
16
- groundRay.hit = getRayHit({
17
- ray: groundRay,
18
- ref: colliderRef,
19
- });
20
- groundRay.parent = (_b = groundRay.hit) === null || _b === void 0 ? void 0 : _b.collider.parent();
21
- return (_jsx(CuboidCollider, { ref: ref, args: [airplaneSizeX / 2, airplaneSizeY / 2, airplaneSizeZ / 2], position: [0, airplaneSizeY / 2, 0] }));
22
- });
@@ -1,6 +0,0 @@
1
- /// <reference types="react" />
2
- import { Collider } from "@dimforge/rapier3d-compat";
3
- import { controllerInnerType } from "../../../controller/type";
4
- export declare const CharacterCapsuleCollider: import("react").ForwardRefExoticComponent<{
5
- props: controllerInnerType;
6
- } & import("react").RefAttributes<Collider>>;
@@ -1,24 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { CapsuleCollider, useRapier } from "@react-three/rapier";
3
- import { forwardRef, useContext } from "react";
4
- import { getRayHit, useForwardRef } from "../../../utils";
5
- import { GaesupWorldContext } from "../../../world/context";
6
- export var CharacterCapsuleCollider = forwardRef(function (_a, ref) {
7
- var _b;
8
- var props = _a.props;
9
- var collider = useContext(GaesupWorldContext).characterCollider;
10
- var colliderRef = useForwardRef(ref);
11
- var rapier = useRapier().rapier;
12
- var groundRay = props.groundRay, slopeRay = props.slopeRay;
13
- groundRay.length = collider.radius + 2;
14
- groundRay.rayCast = new rapier.Ray(groundRay.origin, groundRay.dir);
15
- groundRay.hit = getRayHit({
16
- ray: groundRay,
17
- ref: colliderRef,
18
- });
19
- groundRay.parent = (_b = groundRay.hit) === null || _b === void 0 ? void 0 : _b.collider.parent();
20
- slopeRay.rayCast = new rapier.Ray(slopeRay.origin, slopeRay.dir);
21
- slopeRay.length = collider.radius + 3;
22
- slopeRay.rayCast = new rapier.Ray(slopeRay.origin, slopeRay.dir);
23
- return (_jsx(CapsuleCollider, { ref: ref, args: [collider.height, collider.radius], position: [0, collider.height + collider.radius, 0] }));
24
- });