gaesup-world 0.0.782 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (110) hide show
  1. package/LICENSE.txt +21 -0
  2. package/README.md +277 -8
  3. package/dist/gaesup/animation/actions.d.ts +7 -4
  4. package/dist/gaesup/animation/actions.js +77 -75
  5. package/dist/gaesup/camera/control/normal.js +1 -1
  6. package/dist/gaesup/camera/control/orbit.d.ts +2 -0
  7. package/dist/gaesup/camera/control/orbit.js +9 -5
  8. package/dist/gaesup/camera/index.js +75 -11
  9. package/dist/gaesup/component/active/airplane/index.js +3 -4
  10. package/dist/gaesup/component/active/character/index.js +1 -1
  11. package/dist/gaesup/component/active/common/InnerGroupRef.js +5 -2
  12. package/dist/gaesup/component/active/common/RiderGroupRef.d.ts +7 -0
  13. package/dist/gaesup/component/active/common/RiderGroupRef.js +32 -0
  14. package/dist/gaesup/component/active/common/RigidbodyRef.d.ts +1 -0
  15. package/dist/gaesup/component/active/common/RigidbodyRef.js +2 -2
  16. package/dist/gaesup/component/active/common/WrapperRef.d.ts +2 -1
  17. package/dist/gaesup/component/active/common/WrapperRef.js +2 -2
  18. package/dist/gaesup/component/active/vehicle/collider.js +2 -2
  19. package/dist/gaesup/component/active/vehicle/index.js +3 -4
  20. package/dist/gaesup/component/active/vehicle/wheel.js +1 -1
  21. package/dist/gaesup/component/passive/airplane/index.js +7 -7
  22. package/dist/gaesup/component/passive/airplane/type.d.ts +2 -0
  23. package/dist/gaesup/component/passive/common/RigidbodyRef.d.ts +2 -1
  24. package/dist/gaesup/component/passive/common/RigidbodyRef.js +3 -3
  25. package/dist/gaesup/component/passive/vehicle/index.js +7 -2
  26. package/dist/gaesup/component/passive/vehicle/type.d.ts +2 -0
  27. package/dist/gaesup/controller/index.d.ts +1 -0
  28. package/dist/gaesup/controller/index.js +7 -1
  29. package/dist/gaesup/controller/initialize/callback/index.js +3 -5
  30. package/dist/gaesup/controller/initialize/callback/type.d.ts +2 -1
  31. package/dist/gaesup/controller/initialize/index.js +0 -1
  32. package/dist/gaesup/controller/type.d.ts +1 -0
  33. package/dist/gaesup/gaesupProps/index.d.ts +2 -1
  34. package/dist/gaesup/gaesupProps/index.js +7 -3
  35. package/dist/gaesup/hooks/useGaesupAnimation/index.d.ts +8 -0
  36. package/dist/gaesup/hooks/useGaesupAnimation/index.js +94 -0
  37. package/dist/gaesup/{tools/joystick/default.d.ts → hooks/useJoyStick/index.d.ts} +1 -1
  38. package/dist/gaesup/{tools/joystick/default.js → hooks/useJoyStick/index.js} +1 -1
  39. package/dist/gaesup/hooks/useRideable/index.d.ts +28 -0
  40. package/dist/gaesup/hooks/useRideable/index.js +198 -0
  41. package/dist/gaesup/hooks/useTeleport/index.d.ts +3 -0
  42. package/dist/gaesup/hooks/useTeleport/index.js +12 -0
  43. package/dist/gaesup/physics/airplane/direction.js +0 -1
  44. package/dist/gaesup/physics/airplane/index.js +2 -0
  45. package/dist/gaesup/physics/airplane/landing.d.ts +2 -0
  46. package/dist/gaesup/physics/airplane/landing.js +29 -0
  47. package/dist/gaesup/physics/character/direction.d.ts +1 -1
  48. package/dist/gaesup/physics/check/index.js +4 -0
  49. package/dist/gaesup/physics/check/push.d.ts +2 -0
  50. package/dist/gaesup/physics/check/push.js +6 -0
  51. package/dist/gaesup/physics/check/riding.d.ts +2 -0
  52. package/dist/gaesup/physics/check/riding.js +7 -0
  53. package/dist/gaesup/physics/index.js +8 -5
  54. package/dist/gaesup/physics/vehicle/direction.js +0 -6
  55. package/dist/gaesup/physics/vehicle/index.js +2 -0
  56. package/dist/gaesup/physics/vehicle/landing.d.ts +2 -0
  57. package/dist/gaesup/physics/vehicle/landing.js +29 -0
  58. package/dist/gaesup/tools/{gameboy → gameBoy}/GameBoyButton.js +1 -1
  59. package/dist/gaesup/tools/{gamepad → gamePad}/GamePadButton.js +1 -1
  60. package/dist/gaesup/tools/{gamepad → gamePad}/index.d.ts +4 -1
  61. package/dist/gaesup/tools/{gamepad → gamePad}/index.js +5 -2
  62. package/dist/gaesup/tools/{joystick → joyStick}/index.js +5 -11
  63. package/dist/gaesup/tools/jumpPortal/index.d.ts +2 -2
  64. package/dist/gaesup/tools/jumpPortal/index.js +6 -7
  65. package/dist/gaesup/tools/keyBoardToolTip/type.d.ts +2 -0
  66. package/dist/gaesup/tools/miniMap/index.js +72 -0
  67. package/dist/gaesup/tools/{minimap → miniMap}/type.d.ts +4 -1
  68. package/dist/gaesup/tools/rideable/index.d.ts +3 -0
  69. package/dist/gaesup/tools/rideable/index.js +80 -0
  70. package/dist/gaesup/tools/zoomButton/index.d.ts +17 -0
  71. package/dist/gaesup/tools/zoomButton/index.js +123 -0
  72. package/dist/gaesup/world/context/index.js +20 -6
  73. package/dist/gaesup/world/context/reducer.d.ts +9 -2
  74. package/dist/gaesup/world/context/type.d.ts +41 -5
  75. package/dist/gaesup/world/debug/index.js +1 -23
  76. package/dist/gaesup/world/index.d.ts +1 -0
  77. package/dist/gaesup/world/index.js +4 -2
  78. package/dist/gaesup/world/initalize/index.d.ts +9 -2
  79. package/dist/gaesup/world/initalize/index.js +12 -2
  80. package/dist/gaesup/world/type.d.ts +4 -0
  81. package/dist/index.d.ts +19 -1
  82. package/dist/index.js +19 -1
  83. package/package.json +7 -4
  84. package/yarn-error.log +12152 -0
  85. package/dist/gaesup/component/passive/vehicle/collider.d.ts +0 -6
  86. package/dist/gaesup/component/passive/vehicle/collider.js +0 -7
  87. package/dist/gaesup/index.d.ts +0 -11
  88. package/dist/gaesup/index.js +0 -11
  89. package/dist/gaesup/tools/gamepad/default.d.ts +0 -3
  90. package/dist/gaesup/tools/gamepad/default.js +0 -3
  91. package/dist/gaesup/tools/index.d.ts +0 -6
  92. package/dist/gaesup/tools/index.js +0 -6
  93. package/dist/gaesup/tools/minimap/index.js +0 -58
  94. /package/dist/gaesup/{tools/pushKey → hooks/usePushKey}/index.d.ts +0 -0
  95. /package/dist/gaesup/{tools/pushKey → hooks/usePushKey}/index.js +0 -0
  96. /package/dist/gaesup/tools/{gameboy → gameBoy}/GameBoyButton.d.ts +0 -0
  97. /package/dist/gaesup/tools/{gameboy → gameBoy}/index.d.ts +0 -0
  98. /package/dist/gaesup/tools/{gameboy → gameBoy}/index.js +0 -0
  99. /package/dist/gaesup/tools/{gameboy → gameBoy}/type.d.ts +0 -0
  100. /package/dist/gaesup/tools/{gameboy → gameBoy}/type.js +0 -0
  101. /package/dist/gaesup/tools/{gamepad → gamePad}/GamePadButton.d.ts +0 -0
  102. /package/dist/gaesup/tools/{gamepad → gamePad}/type.d.ts +0 -0
  103. /package/dist/gaesup/tools/{gamepad → gamePad}/type.js +0 -0
  104. /package/dist/gaesup/tools/{joystick → joyStick}/index.d.ts +0 -0
  105. /package/dist/gaesup/tools/{joystick → joyStick}/type.d.ts +0 -0
  106. /package/dist/gaesup/tools/{joystick → joyStick}/type.js +0 -0
  107. /package/dist/gaesup/tools/{minimap → miniMap}/default.d.ts +0 -0
  108. /package/dist/gaesup/tools/{minimap → miniMap}/default.js +0 -0
  109. /package/dist/gaesup/tools/{minimap → miniMap}/index.d.ts +0 -0
  110. /package/dist/gaesup/tools/{minimap → miniMap}/type.js +0 -0
package/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 jigglypop
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -179,22 +179,291 @@ This is the airplane control in Gaesup World. Characters can board the airplane.
179
179
 
180
180
  ---
181
181
 
182
- ## Tools
182
+ # Tools
183
183
 
184
- #### [Tools](#tools)
184
+ - 개숲월드에서 캐릭터 컨트롤을 도와주는 다양한 도구들입니다.
185
185
 
186
- #### [joystick](#joystick)
186
+ #### 1) [joystick](#joystick)
187
187
 
188
- #### [keyboardtooltip](#keyboard tooltip)
188
+ #### 2) [keyboardtooltip](#keyBoardTooltip)
189
189
 
190
190
  #### [minimap](#minimap)
191
191
 
192
192
  #### [gameboy](#gameboy)
193
193
 
194
- ## joystick
194
+ 1. JoyStick
195
195
 
196
- ## keyboard tooltip
196
+ - This component provides a virtual joystick interface. It is recommended for use in mobile environments.
197
197
 
198
- ## minimap
198
+ > Caution! Due to position fluctuation in mobile environments, it is recommended to use the scrollBlock option of GaesupWorld.
199
199
 
200
- ## gameboy
200
+ ### (2) Features
201
+
202
+ Joystick Interface for Mobile and Other Environments: Provides a joystick interface in environments like mobile.
203
+ Custom Appearance: Receives joyStickBallStyle and joyStickStyle properties for styling the joystick and its ball.
204
+ Responsive and Interactive: Supports mouse and mobile touch events to cater to various devices.
205
+
206
+ ### (3) Props
207
+
208
+ joyStickBallStyle: Style of the joystick ball (React.CSSProperties object).
209
+ joyStickStyle: Style of the joystick container (React.CSSProperties object).
210
+
211
+ ### (4) How To Use
212
+
213
+ - Include the JoyStick component in your `GaesupWorld` component tree.
214
+
215
+ > It is imperative to use it inside the GaesupWorld component
216
+
217
+ - The component responds to mouse and touch inputs to control movement.
218
+
219
+ - (Optional) Customize the necessary style using joyStickBallStyle and joyStickStyle.
220
+
221
+ ### (5) Example
222
+
223
+ ```jsx
224
+ const MyComponent = () => {
225
+ // 커스텀 스타일 정의
226
+ const joyStickStyle = {
227
+ /* 여기에 조이스틱 컨테이너 스타일을 정의하세요 */
228
+ };
229
+ const joyStickBallStyle = {
230
+ /* 여기에 조이스틱 공의 스타일을 정의하세요 */
231
+ };
232
+
233
+ return (
234
+ <JoyStick
235
+ joyStickStyle={joyStickStyle}
236
+ joyStickBallStyle={joyStickBallStyle}
237
+ />
238
+ );
239
+ };
240
+ ```
241
+
242
+ ## 2) keyBoardTooltip
243
+
244
+ ### (1) 개요
245
+
246
+ - 키보드 컨트롤러 인터페이스를 시각적으로 표시하기 위해 만든 컴포넌트입니다. 키보드의 각 키와 연결된 액션을 시각적으로 나타냅니다.
247
+
248
+ ### (2) 특징
249
+
250
+ - **키 배열 시각화** : 키보드의 모든 키를 배열 형태로 시각화합니다.
251
+ - **애니메이션 상태 반영** : 현재 활성화된 키와 연관된 액션을 다른 스타일로 표시하여 사용자에게 피드백을 제공합니다.
252
+ - **커스텀 스타일링** : 키 캡의 스타일을 사용자 정의할 수 있도록 다양한 스타일링 속성을 제공합니다.
253
+
254
+ ### (3) How To Use
255
+
256
+ 1. `KeyBoardToolTip` 컴포넌트를 `GaesupWorld` 컴포넌트에 포함시킵니다.
257
+ 2. mode의 `control`는 `keyboard` 로 정의합니다.
258
+ 3. 컴포넌트는 `KeyBoardAll` 상수에 따라 키보드의 각 키를 시각화하고, 현재 활성화된 키에 대해 다른 스타일을 적용합니다.
259
+ 4. (선택) 필요한 스타일을 `keyBoardToolTipInnerStyle`, `selectedKeyCapStyle`, `notSelectedkeyCapStyle`, `keyCapStyle` 속성을 통해 전달합니다.
260
+
261
+ ### (5) Example
262
+
263
+ ```jsx
264
+ import { KeyBoardToolTip } from "./KeyBoardToolTip";
265
+ import { GaesupWorldContext } from "../../world/context";
266
+
267
+ const MyComponent = () => {
268
+ const keyBoardToolTipInnerStyle = {
269
+ /* ... */
270
+ };
271
+ const selectedKeyCapStyle = {
272
+ /* ... */
273
+ };
274
+ const notSelectedkeyCapStyle = {
275
+ /* ... */
276
+ };
277
+ const keyCapStyle = {
278
+ /* ... */
279
+ };
280
+
281
+ return (
282
+ <GaesupWorld>
283
+ {/* ... */}
284
+ <KeyBoardToolTip
285
+ keyBoardToolTipInnerStyle={keyBoardToolTipInnerStyle}
286
+ selectedKeyCapStyle={selectedKeyCapStyle}
287
+ notSelectedkeyCapStyle={notSelectedkeyCapStyle}
288
+ keyCapStyle={keyCapStyle}
289
+ />
290
+ {/* ... */}
291
+ </GaesupWorld>
292
+ );
293
+ };
294
+ ```
295
+
296
+ ## 3) minimap
297
+
298
+ ### (1) Info
299
+
300
+ - 3D 월드 내에서 사용자의 위치와 주변 환경을 작은 지도 형태로 보여주는 리액트 컴포넌트입니다. 이 컴포넌트는 `GaesupWorldContext`를 활용하여 사용자의 현재 상태와 모드에 따라 다르게 렌더링됩니다.
301
+
302
+ ### (2) 특징
303
+
304
+ - **동적 스케일 조절**: 사용자가 지도의 크기를 동적으로 조절할 수 있습니다.
305
+ - **방향 표시**: 동(East), 서(West), 남(South), 북(North) 방향을 시각적으로 표시합니다.
306
+ - **커스텀 스타일링**: 미니맵 및 그 내부 요소들의 스타일을 사용자 정의할 수 있습니다.
307
+ - **마우스 휠 지원**: 마우스 휠을 사용하여 미니맵의 스케일을 조절할 수 있습니다.
308
+
309
+ ### (3) 사용 방법
310
+
311
+ 1. `MiniMap` 컴포넌트를 컴포넌트 트리에 포함시킵니다.
312
+ 2. 필요한 스타일을 `minimapStyle`, `innerStyle`, `textStyle`, `objectStyle`, `avatarStyle`, `scaleStyle`, `directionStyle`, `plusMinusStyle` 속성을 통해 전달합니다.
313
+ 3. 컴포넌트는 현재 사용자의 위치와 방향에 따라 미니맵을 업데이트합니다.
314
+
315
+ ### (4) Example
316
+
317
+ ```jsx
318
+ import { MiniMap } from "./MiniMap";
319
+
320
+ const MyComponent = () => {
321
+ const minimapStyle = {
322
+ /* ... */
323
+ };
324
+ const innerStyle = {
325
+ /* ... */
326
+ };
327
+ // 다른 스타일 속성들도 정의
328
+
329
+ return (
330
+ <GaesupWorld>
331
+ {/* ... */}
332
+ <MiniMap
333
+ minimapStyle={minimapStyle}
334
+ innerStyle={innerStyle}
335
+ // 다른 스타일 속성들 전달
336
+ />
337
+ {/* ... */}
338
+ </GaesupWorld>
339
+ );
340
+ };
341
+ ```
342
+
343
+ ## GameBoy
344
+
345
+ ## 개요
346
+
347
+ - GameBoy 컨트롤러 인터페이스입니다. 게임 4방향 키처럼 사용할 수 있으며, 모바일에서 사용을 권장합니다.
348
+
349
+ ## 특징
350
+
351
+ - **방향 버튼**: `GameBoyDirections` 배열을 사용하여 방향 입력 (앞으로, 뒤로, 왼쪽으로, 오른쪽으로)을 위한 버튼을 구현합니다.
352
+ - **컨텍스트 인식 렌더링**: `GaesupWorldContext`에서 `mode.controller` 값에 따라 컴포넌트를 렌더링합니다.
353
+ - **커스텀 스타일링**: 스타일링을 위한 `gameboyStyle` 및 `gameboyButtonStyle` 속성을 받습니다.
354
+
355
+ ## 사용 방법
356
+
357
+ `GameBoy` 컴포넌트를 사용하기 위해:
358
+
359
+ 1. 컴포넌트 트리에 배치합니다.
360
+ 2. 필요한 스타일을 `gameboyStyle` 및 `gameboyButtonStyle` 속성을 통해 전달합니다.
361
+ 3. 컴포넌트는 `GameBoyDirections` 배열에 기반하여 버튼을 렌더링합니다.
362
+
363
+ ## 예제 코드
364
+
365
+ ```jsx
366
+ import { GameBoy } from "./GameBoy";
367
+ import { GaesupWorldContext } from "../../world/context";
368
+
369
+ const MyComponent = () => {
370
+ // 커스텀 스타일 정의
371
+ const gameboyStyle = {
372
+ /* ... */
373
+ };
374
+ const gameboyButtonStyle = {
375
+ /* ... */
376
+ };
377
+
378
+ return (
379
+ <GameBoy
380
+ gameboyStyle={gameboyStyle}
381
+ gameboyButtonStyle={gameboyButtonStyle}
382
+ />
383
+ );
384
+ };
385
+ ```
386
+
387
+ ## GamePad
388
+
389
+ ## 개요
390
+
391
+ - 게임패드 컨트롤 인터페이스를 제공하는 커스터마이징 가능한 인터페이스입니다. 조이스틱과 GameBoy와 같은 다양한 컨트롤러 모드에 대응할 수 있는 범용성을 가지고 있습니다.
392
+
393
+ ## 특징
394
+
395
+ - **동적 버튼 렌더링**: `GaesupWorldContext`의 `control` 객체에 기반하여 버튼을 생성합니다.
396
+ - **범용적 사용**: 조이스틱 및 GameBoy와 같은 다양한 컨트롤러 모드와 호환됩니다.
397
+ - **커스텀 스타일링**: `gamePadStyle` 및 `gamePadButtonStyle` 속성을 통해 커스텀 스타일링 가능.
398
+
399
+ ## 속성 (Props)
400
+
401
+ - `gamePadStyle`: 게임패드 컨테이너의 스타일 (`React.CSSProperties` 객체).
402
+ - `gamePadButtonStyle`: 개별 버튼의 스타일 (`React.CSSProperties` 객체).
403
+ - `label`: 버튼에 대한 커스텀 라벨.
404
+
405
+ ## 사용 방법
406
+
407
+ 1. `GamePad` 컴포넌트를 컴포넌트 트리에 배치합니다.
408
+ 2. `gamePadStyle` 및 `gamePadButtonStyle`을 사용하여 외관을 커스터마이즈합니다.
409
+ 3. 컴포넌트는 컨트롤러 모드에 맞춰 적절한 버튼을 렌더링합니다.
410
+
411
+ ## 예제 코드
412
+
413
+ ```tsx
414
+ import { GamePad } from "./GamePad";
415
+ import { GaesupWorldContext } from "../../world/context";
416
+
417
+ const MyComponent = () => {
418
+ const gamePadStyle = {
419
+ /* 여기에 커스텀 스타일을 정의하세요 */
420
+ };
421
+ const gamePadButtonStyle = {
422
+ /* 여기에 버튼의 커스텀 스타일을 정의하세요 */
423
+ };
424
+
425
+ return (
426
+ <GamePad
427
+ gamePadStyle={gamePadStyle}
428
+ gamePadButtonStyle={gamePadButtonStyle}
429
+ />
430
+ );
431
+ };
432
+ ```
433
+
434
+ ## ZoomButton
435
+
436
+ ## 개요
437
+
438
+ - 특정 위치로 카메라를 이동시키기 위한 버튼이고 카메라의 zoom 컨트롤을 주로 수행합니다. target에 특정 물체를 넣을 수도 있습니다.
439
+
440
+ ## 속성 (Props)
441
+
442
+ - `position`: 카메라가 이동할 대상 위치 (`THREE.Vector3` 객체).
443
+ - `children`: (선택사항) 버튼 내에 렌더링될 React 노드.
444
+ - `target`: (선택사항) 카메라가 바라볼 대상 위치 (`THREE.Vector3` 객체).
445
+ - `keepBlocking`: (선택사항) 카메라 이동 중 블로킹 상태를 유지할지 여부.
446
+ - `zoomButtonStyle`: (선택사항) 버튼의 스타일 (`React.CSSProperties` 객체).
447
+
448
+ ## 사용 방법
449
+
450
+ 1. `ZoomButton` 컴포넌트를 원하는 위치에 배치합니다.
451
+ 2. `position` prop을 통해 카메라가 이동할 위치를 지정합니다.
452
+ 3. 버튼을 클릭하면 지정된 위치로 카메라가 이동합니다.
453
+
454
+ ## 예제 코드
455
+
456
+ ```tsx
457
+ import { ZoomButton } from "./ZoomButton";
458
+ import * as THREE from "three";
459
+
460
+ const App = () => {
461
+ return (
462
+ <GaesupWorld>
463
+ {/* ... */}
464
+ <ZoomButton position={new THREE.Vector3(0, 0, 5)}>{children}</ZoomButton>
465
+ {/* ... */}
466
+ </GaesupWorld>
467
+ );
468
+ };
469
+ ```
@@ -1,6 +1,6 @@
1
1
  import { Ref } from "react";
2
2
  import { Object3D, Object3DEventMap } from "three";
3
- import { animationTagType, groundRayType } from "../controller/type";
3
+ import { groundRayType } from "../controller/type";
4
4
  export type playActionsType = {
5
5
  groundRay: groundRayType;
6
6
  };
@@ -11,15 +11,18 @@ export type playResultType = {
11
11
  actions: actionsType;
12
12
  ref: Ref<Object3D<Object3DEventMap>>;
13
13
  };
14
- export declare function usePlayActions(): {
14
+ export declare function readyAnimation(): {
15
15
  resultRef: {
16
16
  character: playResultType;
17
17
  vehicle: playResultType;
18
18
  airplane: playResultType;
19
19
  };
20
- play: (tag: keyof animationTagType) => void;
21
- setAnimationName: (actions: actionsType) => void;
22
20
  };
23
21
  export default function playCharacterActions({ groundRay }: playActionsType): {
24
22
  ref: Ref<Object3D<Object3DEventMap>>;
23
+ resultRef: {
24
+ character: playResultType;
25
+ vehicle: playResultType;
26
+ airplane: playResultType;
27
+ };
25
28
  };
@@ -12,26 +12,49 @@ var __assign = (this && this.__assign) || function () {
12
12
  import { useAnimations, useKeyboardControls } from "@react-three/drei";
13
13
  import { useFrame } from "@react-three/fiber";
14
14
  import { useContext, useEffect } from "react";
15
+ import { useGaesupAnimation } from "../hooks/useGaesupAnimation";
15
16
  import { GaesupWorldContext, GaesupWorldDispatchContext, } from "../world/context";
16
- export function usePlayActions() {
17
- var _a = useContext(GaesupWorldContext), characterGltf = _a.characterGltf, vehicleGltf = _a.vehicleGltf, airplaneGltf = _a.airplaneGltf, animations = _a.animations;
17
+ // 캐릭터 등록, 애니메이션 이름 설정, 애니메이션 실행
18
+ export function readyAnimation() {
19
+ var _a = useContext(GaesupWorldContext), characterGltf = _a.characterGltf, vehicleGltf = _a.vehicleGltf, airplaneGltf = _a.airplaneGltf;
18
20
  var resultRef = {
19
21
  character: null,
20
22
  vehicle: null,
21
23
  airplane: null,
22
24
  };
23
- if (characterGltf && characterGltf.animations) {
25
+ if (characterGltf && characterGltf.animations)
24
26
  resultRef.character = useAnimations(characterGltf.animations);
25
- }
26
- if (vehicleGltf && vehicleGltf.animations) {
27
+ if (vehicleGltf && vehicleGltf.animations)
27
28
  resultRef.vehicle = useAnimations(vehicleGltf.animations);
28
- }
29
- if (airplaneGltf && airplaneGltf.animations) {
29
+ if (airplaneGltf && airplaneGltf.animations)
30
30
  resultRef.airplane = useAnimations(airplaneGltf.animations);
31
- }
31
+ return {
32
+ resultRef: resultRef,
33
+ };
34
+ }
35
+ export default function playCharacterActions(_a) {
36
+ var groundRay = _a.groundRay;
37
+ var _b = useContext(GaesupWorldContext), states = _b.states, activeState = _b.activeState, animations = _b.animations, mode = _b.mode, characterGltf = _b.characterGltf, vehicleGltf = _b.vehicleGltf, airplaneGltf = _b.airplaneGltf;
32
38
  var dispatch = useContext(GaesupWorldDispatchContext);
39
+ var control = useKeyboardControls()[1]();
40
+ var _c = useGaesupAnimation(), subscribeAll = _c.subscribeAll, notify = _c.notify, store = _c.store;
41
+ var resultRef = {
42
+ character: null,
43
+ vehicle: null,
44
+ airplane: null,
45
+ };
46
+ if (characterGltf && characterGltf.animations)
47
+ resultRef.character = useAnimations(characterGltf.animations);
48
+ if (vehicleGltf && vehicleGltf.animations)
49
+ resultRef.vehicle = useAnimations(vehicleGltf.animations);
50
+ if (airplaneGltf && airplaneGltf.animations)
51
+ resultRef.airplane = useAnimations(airplaneGltf.animations);
33
52
  var play = function (tag) {
34
53
  animations.current = tag;
54
+ var currentAnimation = store[tag];
55
+ if (currentAnimation === null || currentAnimation === void 0 ? void 0 : currentAnimation.action) {
56
+ currentAnimation.action();
57
+ }
35
58
  dispatch({
36
59
  type: "update",
37
60
  payload: {
@@ -39,39 +62,46 @@ export function usePlayActions() {
39
62
  },
40
63
  });
41
64
  };
42
- var setAnimationName = function (actions) {
43
- animations.animationNames = Object.assign(animations.animationNames, Object.keys(actions).reduce(function (acc, cur) {
44
- var _a;
45
- return __assign(__assign({}, acc), (_a = {}, _a[cur] = cur, _a));
46
- }, {}));
47
- dispatch({
48
- type: "update",
49
- payload: {
50
- animations: __assign({}, animations),
51
- },
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]();
63
- var resetAni = function () { return play("idle"); };
64
- var playIdle = function () { return play("idle"); };
65
- var playWalk = function () { return play("walk"); };
66
- var playRun = function () { return play("run"); };
67
- var playJump = function () { return play("jump"); };
68
- var playFall = function () { return play("fall"); };
69
- var playRide = function () { return play("ride"); };
70
- var playLanding = function () { return play("land"); };
65
+ var _d = resultRef.character, actions = _d.actions, ref = _d.ref;
66
+ // 초기 기본 애니메이션 등록
71
67
  useEffect(function () {
72
- return function () {
73
- resetAni();
74
- };
68
+ subscribeAll([
69
+ {
70
+ tag: "walk",
71
+ condition: function () { return !states.isRunning && states.isMoving; },
72
+ action: function () { },
73
+ animationName: "walk",
74
+ key: "walk",
75
+ },
76
+ {
77
+ tag: "run",
78
+ condition: function () { return states.isRunning; },
79
+ action: function () { },
80
+ animationName: "run",
81
+ key: "run",
82
+ },
83
+ {
84
+ tag: "jump",
85
+ condition: function () { return states.isJumping; },
86
+ action: function () { },
87
+ animationName: "jump",
88
+ key: "jump",
89
+ },
90
+ {
91
+ tag: "fall",
92
+ condition: function () { return groundRay.hit === null && activeState.velocity.y < 0; },
93
+ action: function () { },
94
+ animationName: "fall",
95
+ key: "fall",
96
+ },
97
+ {
98
+ tag: "ride",
99
+ condition: function () { return states.isPush["keyR"]; },
100
+ action: function () { },
101
+ animationName: "ride",
102
+ key: "ride",
103
+ },
104
+ ]);
75
105
  }, []);
76
106
  useEffect(function () {
77
107
  animations.keyControl = control;
@@ -84,45 +114,17 @@ export default function playCharacterActions(_a) {
84
114
  }, [control]);
85
115
  useEffect(function () {
86
116
  var _a;
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
- };
93
- }
117
+ var action = (_a = actions[animations.current]) === null || _a === void 0 ? void 0 : _a.reset().fadeIn(0.2).play();
118
+ return function () {
119
+ action === null || action === void 0 ? void 0 : action.fadeOut(0.2);
120
+ };
94
121
  }, [animations.current, mode.type]);
95
122
  useFrame(function () {
96
- if (mode.type === "character") {
97
- if (!isAnimationOuter) {
98
- if (isJumping) {
99
- playJump();
100
- }
101
- else if (isNotMoving) {
102
- playIdle();
103
- }
104
- else if (isRunning) {
105
- playRun();
106
- }
107
- else if (isMoving) {
108
- playWalk();
109
- }
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
- // }
122
- }
123
- }
123
+ var tag = notify();
124
+ play(tag);
124
125
  });
125
126
  return {
126
127
  ref: ref,
128
+ resultRef: resultRef,
127
129
  };
128
130
  }
@@ -6,6 +6,6 @@ export default function normal(prop) {
6
6
  var cameraPosition = activeState.position
7
7
  .clone()
8
8
  .add(V3(0, cameraOption.YDistance, cameraOption.XZDistance));
9
- state.camera.position.lerp(cameraPosition, 0.9);
9
+ state.camera.position.lerp(cameraPosition, 1);
10
10
  state.camera.lookAt(activeState.position.clone());
11
11
  }
@@ -1,2 +1,4 @@
1
1
  import { cameraPropType } from "../../physics/type";
2
+ import { activeStateType, cameraOptionType } from "../../world/context/type";
3
+ export declare const makeCameraPosition: (activeState: activeStateType, cameraOption: cameraOptionType) => import("three").Vector3;
2
4
  export default function orbit(prop: cameraPropType): void;
@@ -1,14 +1,18 @@
1
1
  import { quat } from "@react-three/rapier";
2
2
  import { V3 } from "../../utils/vector";
3
+ export var makeCameraPosition = function (activeState, cameraOption) {
4
+ var XDistance = cameraOption.XDistance, YDistance = cameraOption.YDistance, ZDistance = cameraOption.ZDistance;
5
+ var cameraPosition = activeState.position.clone().add(V3(Math.sin(activeState.euler.y), 1, Math.cos(activeState.euler.y))
6
+ .normalize()
7
+ .clone()
8
+ .multiply(V3(-XDistance, YDistance, -ZDistance)));
9
+ return cameraPosition;
10
+ };
3
11
  export default function orbit(prop) {
4
12
  var state = prop.state, _a = prop.worldContext, activeState = _a.activeState, cameraOption = _a.cameraOption;
5
13
  if (!state || !state.camera)
6
14
  return;
7
- var cameraPosition = activeState.position.clone().add(V3(Math.sin(activeState.euler.y), 0, Math.cos(activeState.euler.y))
8
- .normalize()
9
- .clone()
10
- .multiplyScalar(-cameraOption.XZDistance)
11
- .add(V3(0, cameraOption.YDistance, 0)));
15
+ var cameraPosition = makeCameraPosition(activeState, cameraOption);
12
16
  state.camera.position.lerp(cameraPosition, 1);
13
17
  state.camera.quaternion.copy(activeState.quat
14
18
  .clone()