gaesup-world 0.0.782 → 0.0.783
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.txt +21 -0
- package/README.md +273 -8
- package/dist/gaesup/camera/control/orbit.d.ts +2 -0
- package/dist/gaesup/camera/control/orbit.js +9 -5
- package/dist/gaesup/camera/index.js +75 -11
- package/dist/gaesup/component/active/character/index.js +1 -1
- package/dist/gaesup/component/active/common/RigidbodyRef.d.ts +1 -0
- package/dist/gaesup/component/active/common/RigidbodyRef.js +2 -2
- package/dist/gaesup/component/active/common/WrapperRef.d.ts +2 -1
- package/dist/gaesup/component/active/common/WrapperRef.js +2 -2
- package/dist/gaesup/component/active/vehicle/collider.js +2 -2
- package/dist/gaesup/component/active/vehicle/wheel.js +1 -1
- package/dist/gaesup/component/index.js +1 -1
- package/dist/gaesup/controller/initialize/index.js +0 -1
- package/dist/gaesup/controller/type.d.ts +1 -0
- package/dist/gaesup/{tools/joystick/default.d.ts → hooks/useJoyStick/index.d.ts} +1 -1
- package/dist/gaesup/{tools/joystick/default.js → hooks/useJoyStick/index.js} +1 -1
- package/dist/gaesup/physics/character/direction.d.ts +1 -1
- package/dist/gaesup/physics/index.js +8 -5
- package/dist/gaesup/tools/{gameboy → gameBoy}/GameBoyButton.js +1 -1
- package/dist/gaesup/tools/{gamepad → gamePad}/GamePadButton.js +1 -1
- package/dist/gaesup/tools/{gamepad → gamePad}/index.d.ts +4 -1
- package/dist/gaesup/tools/{gamepad → gamePad}/index.js +5 -2
- package/dist/gaesup/tools/{joystick → joyStick}/index.js +5 -11
- package/dist/gaesup/tools/jumpPortal/index.d.ts +1 -1
- package/dist/gaesup/tools/jumpPortal/index.js +1 -1
- package/dist/gaesup/tools/rideable/index.d.ts +9 -0
- package/dist/gaesup/tools/rideable/index.js +115 -0
- package/dist/gaesup/tools/zoomButton/index.d.ts +10 -0
- package/dist/gaesup/tools/zoomButton/index.js +99 -0
- package/dist/gaesup/world/context/index.js +10 -0
- package/dist/gaesup/world/context/reducer.d.ts +7 -2
- package/dist/gaesup/world/context/type.d.ts +13 -2
- package/dist/gaesup/world/index.d.ts +1 -0
- package/dist/gaesup/world/index.js +4 -2
- package/dist/gaesup/world/initalize/index.d.ts +7 -2
- package/dist/gaesup/world/initalize/index.js +11 -1
- package/dist/gaesup/world/type.d.ts +4 -0
- package/dist/index.d.ts +19 -1
- package/dist/index.js +19 -1
- package/package.json +4 -2
- package/yarn-error.log +12152 -0
- package/dist/gaesup/index.d.ts +0 -11
- package/dist/gaesup/index.js +0 -11
- package/dist/gaesup/tools/gamepad/default.d.ts +0 -3
- package/dist/gaesup/tools/gamepad/default.js +0 -3
- package/dist/gaesup/tools/index.d.ts +0 -6
- package/dist/gaesup/tools/index.js +0 -6
- /package/dist/gaesup/{tools/pushKey → hooks/usePushKey}/index.d.ts +0 -0
- /package/dist/gaesup/{tools/pushKey → hooks/usePushKey}/index.js +0 -0
- /package/dist/gaesup/tools/{gameboy → gameBoy}/GameBoyButton.d.ts +0 -0
- /package/dist/gaesup/tools/{gameboy → gameBoy}/index.d.ts +0 -0
- /package/dist/gaesup/tools/{gameboy → gameBoy}/index.js +0 -0
- /package/dist/gaesup/tools/{gameboy → gameBoy}/type.d.ts +0 -0
- /package/dist/gaesup/tools/{gameboy → gameBoy}/type.js +0 -0
- /package/dist/gaesup/tools/{gamepad → gamePad}/GamePadButton.d.ts +0 -0
- /package/dist/gaesup/tools/{gamepad → gamePad}/type.d.ts +0 -0
- /package/dist/gaesup/tools/{gamepad → gamePad}/type.js +0 -0
- /package/dist/gaesup/tools/{joystick → joyStick}/index.d.ts +0 -0
- /package/dist/gaesup/tools/{joystick → joyStick}/type.d.ts +0 -0
- /package/dist/gaesup/tools/{joystick → joyStick}/type.js +0 -0
- /package/dist/gaesup/tools/{minimap → miniMap}/default.d.ts +0 -0
- /package/dist/gaesup/tools/{minimap → miniMap}/default.js +0 -0
- /package/dist/gaesup/tools/{minimap → miniMap}/index.d.ts +0 -0
- /package/dist/gaesup/tools/{minimap → miniMap}/index.js +0 -0
- /package/dist/gaesup/tools/{minimap → miniMap}/type.d.ts +0 -0
- /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,287 @@ This is the airplane control in Gaesup World. Characters can board the airplane.
|
|
|
179
179
|
|
|
180
180
|
---
|
|
181
181
|
|
|
182
|
-
|
|
182
|
+
# Tools
|
|
183
183
|
|
|
184
|
-
|
|
184
|
+
- 개숲월드에서 캐릭터 컨트롤을 도와주는 다양한 도구들입니다.
|
|
185
185
|
|
|
186
|
-
#### [joystick](#joystick)
|
|
186
|
+
#### 1) [joystick](#joystick)
|
|
187
187
|
|
|
188
|
-
#### [keyboardtooltip](#
|
|
188
|
+
#### 2) [keyboardtooltip](#keyBoardTooltip)
|
|
189
189
|
|
|
190
190
|
#### [minimap](#minimap)
|
|
191
191
|
|
|
192
192
|
#### [gameboy](#gameboy)
|
|
193
193
|
|
|
194
|
-
##
|
|
194
|
+
## 1) joyStick
|
|
195
195
|
|
|
196
|
-
|
|
196
|
+
### (1) Info
|
|
197
197
|
|
|
198
|
-
|
|
198
|
+
- 가상 조이스틱 인터페이스를 제공하는 컴포넌트입니다. 모바일 환경에서 사용을 권장합니다
|
|
199
199
|
|
|
200
|
-
|
|
200
|
+
> 주의! 모바일에서 위치의 흔들림 때문에 `GaesupWorld` 의 옵션 `scrollBlock` 의 사용을 권장합니다.
|
|
201
|
+
|
|
202
|
+
### (2) 특징
|
|
203
|
+
|
|
204
|
+
- **모바일 등에서 조이스틱 인터페이스 제공**: 모바일 등의 환경에서 조이스틱 인터페이스를 제공합니다
|
|
205
|
+
- **커스텀 외관**: 조이스틱과 그 공의 스타일링을 위한 `joyStickBallStyle` 및 `joyStickStyle` 속성을 받습니다.
|
|
206
|
+
- **반응형 및 상호작용**: 다양한 장치에 대응하기 위한 마우스, 모바일 터치 이벤트를 지원합니다.
|
|
207
|
+
|
|
208
|
+
### (3) Props
|
|
209
|
+
|
|
210
|
+
- `joyStickBallStyle`: 조이스틱 공의 스타일 (`React.CSSProperties` 객체).
|
|
211
|
+
- `joyStickStyle`: 조이스틱 컨테이너의 스타일 (`React.CSSProperties` 객체).
|
|
212
|
+
|
|
213
|
+
### (4) How To Use
|
|
214
|
+
|
|
215
|
+
1. 컴포넌트 트리에 `JoyStick` 컴포넌트를 포함시킵니다.
|
|
216
|
+
2. 컴포넌트는 마우스 및 터치 입력에 반응하여 이동을 제어합니다.
|
|
217
|
+
3. (선택) `joyStickBallStyle` 및 `joyStickStyle`을 통해 필요한 스타일을 커스텀합니다
|
|
218
|
+
|
|
219
|
+
### (5) Example
|
|
220
|
+
|
|
221
|
+
```jsx
|
|
222
|
+
const MyComponent = () => {
|
|
223
|
+
// 커스텀 스타일 정의
|
|
224
|
+
const joyStickStyle = {
|
|
225
|
+
/* 여기에 조이스틱 컨테이너 스타일을 정의하세요 */
|
|
226
|
+
};
|
|
227
|
+
const joyStickBallStyle = {
|
|
228
|
+
/* 여기에 조이스틱 공의 스타일을 정의하세요 */
|
|
229
|
+
};
|
|
230
|
+
|
|
231
|
+
return (
|
|
232
|
+
<JoyStick
|
|
233
|
+
joyStickStyle={joyStickStyle}
|
|
234
|
+
joyStickBallStyle={joyStickBallStyle}
|
|
235
|
+
/>
|
|
236
|
+
);
|
|
237
|
+
};
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
## 2) keyBoardTooltip
|
|
241
|
+
|
|
242
|
+
### (1) 개요
|
|
243
|
+
|
|
244
|
+
- 키보드 컨트롤러 인터페이스를 시각적으로 표시하기 위해 만든 컴포넌트입니다. 키보드의 각 키와 연결된 액션을 시각적으로 나타냅니다.
|
|
245
|
+
|
|
246
|
+
### (2) 특징
|
|
247
|
+
|
|
248
|
+
- **키 배열 시각화** : 키보드의 모든 키를 배열 형태로 시각화합니다.
|
|
249
|
+
- **애니메이션 상태 반영** : 현재 활성화된 키와 연관된 액션을 다른 스타일로 표시하여 사용자에게 피드백을 제공합니다.
|
|
250
|
+
- **커스텀 스타일링** : 키 캡의 스타일을 사용자 정의할 수 있도록 다양한 스타일링 속성을 제공합니다.
|
|
251
|
+
|
|
252
|
+
### (3) How To Use
|
|
253
|
+
|
|
254
|
+
1. `KeyBoardToolTip` 컴포넌트를 `GaesupWorld` 컴포넌트에 포함시킵니다.
|
|
255
|
+
2. mode의 `control`는 `keyboard` 로 정의합니다.
|
|
256
|
+
3. 컴포넌트는 `KeyBoardAll` 상수에 따라 키보드의 각 키를 시각화하고, 현재 활성화된 키에 대해 다른 스타일을 적용합니다.
|
|
257
|
+
4. (선택) 필요한 스타일을 `keyBoardToolTipInnerStyle`, `selectedKeyCapStyle`, `notSelectedkeyCapStyle`, `keyCapStyle` 속성을 통해 전달합니다.
|
|
258
|
+
|
|
259
|
+
### (5) Example
|
|
260
|
+
|
|
261
|
+
```jsx
|
|
262
|
+
import { KeyBoardToolTip } from "./KeyBoardToolTip";
|
|
263
|
+
import { GaesupWorldContext } from "../../world/context";
|
|
264
|
+
|
|
265
|
+
const MyComponent = () => {
|
|
266
|
+
const keyBoardToolTipInnerStyle = {
|
|
267
|
+
/* ... */
|
|
268
|
+
};
|
|
269
|
+
const selectedKeyCapStyle = {
|
|
270
|
+
/* ... */
|
|
271
|
+
};
|
|
272
|
+
const notSelectedkeyCapStyle = {
|
|
273
|
+
/* ... */
|
|
274
|
+
};
|
|
275
|
+
const keyCapStyle = {
|
|
276
|
+
/* ... */
|
|
277
|
+
};
|
|
278
|
+
|
|
279
|
+
return (
|
|
280
|
+
<GaesupWorld>
|
|
281
|
+
{/* ... */}
|
|
282
|
+
<KeyBoardToolTip
|
|
283
|
+
keyBoardToolTipInnerStyle={keyBoardToolTipInnerStyle}
|
|
284
|
+
selectedKeyCapStyle={selectedKeyCapStyle}
|
|
285
|
+
notSelectedkeyCapStyle={notSelectedkeyCapStyle}
|
|
286
|
+
keyCapStyle={keyCapStyle}
|
|
287
|
+
/>
|
|
288
|
+
{/* ... */}
|
|
289
|
+
</GaesupWorld>
|
|
290
|
+
);
|
|
291
|
+
};
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
## 3) minimap
|
|
295
|
+
|
|
296
|
+
### (1) Info
|
|
297
|
+
|
|
298
|
+
- 3D 월드 내에서 사용자의 위치와 주변 환경을 작은 지도 형태로 보여주는 리액트 컴포넌트입니다. 이 컴포넌트는 `GaesupWorldContext`를 활용하여 사용자의 현재 상태와 모드에 따라 다르게 렌더링됩니다.
|
|
299
|
+
|
|
300
|
+
### (2) 특징
|
|
301
|
+
|
|
302
|
+
- **동적 스케일 조절**: 사용자가 지도의 크기를 동적으로 조절할 수 있습니다.
|
|
303
|
+
- **방향 표시**: 동(East), 서(West), 남(South), 북(North) 방향을 시각적으로 표시합니다.
|
|
304
|
+
- **커스텀 스타일링**: 미니맵 및 그 내부 요소들의 스타일을 사용자 정의할 수 있습니다.
|
|
305
|
+
- **마우스 휠 지원**: 마우스 휠을 사용하여 미니맵의 스케일을 조절할 수 있습니다.
|
|
306
|
+
|
|
307
|
+
## 사용 방법
|
|
308
|
+
|
|
309
|
+
1. `MiniMap` 컴포넌트를 컴포넌트 트리에 포함시킵니다.
|
|
310
|
+
2. 필요한 스타일을 `minimapStyle`, `innerStyle`, `textStyle`, `objectStyle`, `avatarStyle`, `scaleStyle`, `directionStyle`, `plusMinusStyle` 속성을 통해 전달합니다.
|
|
311
|
+
3. 컴포넌트는 현재 사용자의 위치와 방향에 따라 미니맵을 업데이트합니다.
|
|
312
|
+
|
|
313
|
+
### (4) Example
|
|
314
|
+
|
|
315
|
+
```jsx
|
|
316
|
+
import { MiniMap } from "./MiniMap";
|
|
317
|
+
|
|
318
|
+
const MyComponent = () => {
|
|
319
|
+
const minimapStyle = {
|
|
320
|
+
/* ... */
|
|
321
|
+
};
|
|
322
|
+
const innerStyle = {
|
|
323
|
+
/* ... */
|
|
324
|
+
};
|
|
325
|
+
// 다른 스타일 속성들도 정의
|
|
326
|
+
|
|
327
|
+
return (
|
|
328
|
+
<GaesupWorld>
|
|
329
|
+
{/* ... */}
|
|
330
|
+
<MiniMap
|
|
331
|
+
minimapStyle={minimapStyle}
|
|
332
|
+
innerStyle={innerStyle}
|
|
333
|
+
// 다른 스타일 속성들 전달
|
|
334
|
+
/>
|
|
335
|
+
{/* ... */}
|
|
336
|
+
</GaesupWorld>
|
|
337
|
+
);
|
|
338
|
+
};
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
## GameBoy
|
|
342
|
+
|
|
343
|
+
## 개요
|
|
344
|
+
|
|
345
|
+
- GameBoy 컨트롤러 인터페이스입니다. 게임 4방향 키처럼 사용할 수 있으며, 모바일에서 사용을 권장합니다.
|
|
346
|
+
|
|
347
|
+
## 특징
|
|
348
|
+
|
|
349
|
+
- **방향 버튼**: `GameBoyDirections` 배열을 사용하여 방향 입력 (앞으로, 뒤로, 왼쪽으로, 오른쪽으로)을 위한 버튼을 구현합니다.
|
|
350
|
+
- **컨텍스트 인식 렌더링**: `GaesupWorldContext`에서 `mode.controller` 값에 따라 컴포넌트를 렌더링합니다.
|
|
351
|
+
- **커스텀 스타일링**: 스타일링을 위한 `gameboyStyle` 및 `gameboyButtonStyle` 속성을 받습니다.
|
|
352
|
+
|
|
353
|
+
## 사용 방법
|
|
354
|
+
|
|
355
|
+
`GameBoy` 컴포넌트를 사용하기 위해:
|
|
356
|
+
|
|
357
|
+
1. 컴포넌트 트리에 배치합니다.
|
|
358
|
+
2. 필요한 스타일을 `gameboyStyle` 및 `gameboyButtonStyle` 속성을 통해 전달합니다.
|
|
359
|
+
3. 컴포넌트는 `GameBoyDirections` 배열에 기반하여 버튼을 렌더링합니다.
|
|
360
|
+
|
|
361
|
+
## 예제 코드
|
|
362
|
+
|
|
363
|
+
```jsx
|
|
364
|
+
import { GameBoy } from "./GameBoy";
|
|
365
|
+
import { GaesupWorldContext } from "../../world/context";
|
|
366
|
+
|
|
367
|
+
const MyComponent = () => {
|
|
368
|
+
// 커스텀 스타일 정의
|
|
369
|
+
const gameboyStyle = {
|
|
370
|
+
/* ... */
|
|
371
|
+
};
|
|
372
|
+
const gameboyButtonStyle = {
|
|
373
|
+
/* ... */
|
|
374
|
+
};
|
|
375
|
+
|
|
376
|
+
return (
|
|
377
|
+
<GameBoy
|
|
378
|
+
gameboyStyle={gameboyStyle}
|
|
379
|
+
gameboyButtonStyle={gameboyButtonStyle}
|
|
380
|
+
/>
|
|
381
|
+
);
|
|
382
|
+
};
|
|
383
|
+
```
|
|
384
|
+
|
|
385
|
+
## GamePad
|
|
386
|
+
|
|
387
|
+
## 개요
|
|
388
|
+
|
|
389
|
+
- 게임패드 컨트롤 인터페이스를 제공하는 커스터마이징 가능한 인터페이스입니다. 조이스틱과 GameBoy와 같은 다양한 컨트롤러 모드에 대응할 수 있는 범용성을 가지고 있습니다.
|
|
390
|
+
|
|
391
|
+
## 특징
|
|
392
|
+
|
|
393
|
+
- **동적 버튼 렌더링**: `GaesupWorldContext`의 `control` 객체에 기반하여 버튼을 생성합니다.
|
|
394
|
+
- **범용적 사용**: 조이스틱 및 GameBoy와 같은 다양한 컨트롤러 모드와 호환됩니다.
|
|
395
|
+
- **커스텀 스타일링**: `gamePadStyle` 및 `gamePadButtonStyle` 속성을 통해 커스텀 스타일링 가능.
|
|
396
|
+
|
|
397
|
+
## 속성 (Props)
|
|
398
|
+
|
|
399
|
+
- `gamePadStyle`: 게임패드 컨테이너의 스타일 (`React.CSSProperties` 객체).
|
|
400
|
+
- `gamePadButtonStyle`: 개별 버튼의 스타일 (`React.CSSProperties` 객체).
|
|
401
|
+
- `label`: 버튼에 대한 커스텀 라벨.
|
|
402
|
+
|
|
403
|
+
## 사용 방법
|
|
404
|
+
|
|
405
|
+
1. `GamePad` 컴포넌트를 컴포넌트 트리에 배치합니다.
|
|
406
|
+
2. `gamePadStyle` 및 `gamePadButtonStyle`을 사용하여 외관을 커스터마이즈합니다.
|
|
407
|
+
3. 컴포넌트는 컨트롤러 모드에 맞춰 적절한 버튼을 렌더링합니다.
|
|
408
|
+
|
|
409
|
+
## 예제 코드
|
|
410
|
+
|
|
411
|
+
```jsx
|
|
412
|
+
import { GamePad } from "./GamePad";
|
|
413
|
+
import { GaesupWorldContext } from "../../world/context";
|
|
414
|
+
|
|
415
|
+
const MyComponent = () => {
|
|
416
|
+
const gamePadStyle = {
|
|
417
|
+
/* 여기에 커스텀 스타일을 정의하세요 */
|
|
418
|
+
};
|
|
419
|
+
const gamePadButtonStyle = {
|
|
420
|
+
/* 여기에 버튼의 커스텀 스타일을 정의하세요 */
|
|
421
|
+
};
|
|
422
|
+
|
|
423
|
+
return (
|
|
424
|
+
<GamePad
|
|
425
|
+
gamePadStyle={gamePadStyle}
|
|
426
|
+
gamePadButtonStyle={gamePadButtonStyle}
|
|
427
|
+
/>
|
|
428
|
+
);
|
|
429
|
+
};
|
|
430
|
+
```
|
|
431
|
+
|
|
432
|
+
## ZoomButton
|
|
433
|
+
|
|
434
|
+
## 개요
|
|
435
|
+
|
|
436
|
+
- 특정 위치로 카메라를 이동시키기 위한 버튼이고 카메라의 zoom 컨트롤을 주로 수행합니다. target에 특정 물체를 넣을 수도 있습니다.
|
|
437
|
+
|
|
438
|
+
## 속성 (Props)
|
|
439
|
+
|
|
440
|
+
- `position`: 카메라가 이동할 대상 위치 (`THREE.Vector3` 객체).
|
|
441
|
+
- `children`: (선택사항) 버튼 내에 렌더링될 React 노드.
|
|
442
|
+
- `target`: (선택사항) 카메라가 바라볼 대상 위치 (`THREE.Vector3` 객체).
|
|
443
|
+
- `keepBlocking`: (선택사항) 카메라 이동 중 블로킹 상태를 유지할지 여부.
|
|
444
|
+
- `zoomButtonStyle`: (선택사항) 버튼의 스타일 (`React.CSSProperties` 객체).
|
|
445
|
+
|
|
446
|
+
## 사용 방법
|
|
447
|
+
|
|
448
|
+
1. `ZoomButton` 컴포넌트를 원하는 위치에 배치합니다.
|
|
449
|
+
2. `position` prop을 통해 카메라가 이동할 위치를 지정합니다.
|
|
450
|
+
3. 버튼을 클릭하면 지정된 위치로 카메라가 이동합니다.
|
|
451
|
+
|
|
452
|
+
## 예제 코드
|
|
453
|
+
|
|
454
|
+
```jsx
|
|
455
|
+
import { ZoomButton } from "./ZoomButton";
|
|
456
|
+
import * as THREE from "three";
|
|
457
|
+
|
|
458
|
+
const App = () => {
|
|
459
|
+
return (
|
|
460
|
+
<ZoomButton position={new THREE.Vector3(0, 0, 5)}>
|
|
461
|
+
Zoom to Position
|
|
462
|
+
</ZoomButton>
|
|
463
|
+
);
|
|
464
|
+
};
|
|
465
|
+
```
|
|
@@ -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 =
|
|
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()
|
|
@@ -9,23 +9,61 @@ var __assign = (this && this.__assign) || function () {
|
|
|
9
9
|
};
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
11
|
};
|
|
12
|
-
|
|
12
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
16
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
18
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
22
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
23
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
24
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
25
|
+
function step(op) {
|
|
26
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
27
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
28
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
29
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
30
|
+
switch (op[0]) {
|
|
31
|
+
case 0: case 1: t = op; break;
|
|
32
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
33
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
34
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
35
|
+
default:
|
|
36
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
37
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
38
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
39
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
40
|
+
if (t[2]) _.ops.pop();
|
|
41
|
+
_.trys.pop(); continue;
|
|
42
|
+
}
|
|
43
|
+
op = body.call(thisArg, _);
|
|
44
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
45
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
49
|
import { CameraControls } from "@react-three/drei";
|
|
14
50
|
import { useFrame, useThree } from "@react-three/fiber";
|
|
51
|
+
import { vec3 } from "@react-three/rapier";
|
|
15
52
|
import { useContext, useEffect, useMemo, useRef } from "react";
|
|
16
53
|
import * as THREE from "three";
|
|
17
54
|
import { GaesupControllerContext } from "../controller/context";
|
|
18
55
|
import { GaesupWorldContext } from "../world/context";
|
|
19
56
|
import normal from "./control/normal";
|
|
20
57
|
import orbit from "./control/orbit";
|
|
58
|
+
import detector from "./detector";
|
|
21
59
|
export default function Camera(_a) {
|
|
60
|
+
var _this = this;
|
|
22
61
|
var refs = _a.refs, prop = _a.prop, control = _a.control;
|
|
23
62
|
var worldContext = useContext(GaesupWorldContext);
|
|
24
63
|
var controllerContext = useContext(GaesupControllerContext);
|
|
25
|
-
var mode = worldContext.mode,
|
|
64
|
+
var mode = worldContext.mode, cameraOption = worldContext.cameraOption;
|
|
26
65
|
var rigidBodyRef = refs.rigidBodyRef, outerGroupRef = refs.outerGroupRef;
|
|
27
|
-
var
|
|
28
|
-
var state = useThree();
|
|
66
|
+
var _b = useThree(), scene = _b.scene, camera = _b.camera;
|
|
29
67
|
var cameraRef = useRef();
|
|
30
68
|
var intersectObjectMap = useMemo(function () { return ({}); }, []);
|
|
31
69
|
var cameraProp = __assign(__assign({}, prop), { control: control, controllerContext: controllerContext, worldContext: worldContext, intersectObjectMap: intersectObjectMap });
|
|
@@ -43,20 +81,46 @@ export default function Camera(_a) {
|
|
|
43
81
|
useEffect(function () {
|
|
44
82
|
scene.children.forEach(function (child) { return getMeshs(child); });
|
|
45
83
|
}, []);
|
|
84
|
+
var position = useMemo(function () { return camera.position; }, []);
|
|
85
|
+
var dir = useMemo(function () { return vec3(); }, []);
|
|
86
|
+
cameraProp.cameraRay.rayCast = new THREE.Raycaster(cameraProp.cameraRay.origin, cameraProp.cameraRay.dir, 0, -cameraOption.maxDistance);
|
|
87
|
+
useEffect(function () {
|
|
88
|
+
cameraProp.cameraRay.origin.copy(position);
|
|
89
|
+
cameraProp.cameraRay.dir.copy(camera.getWorldDirection(dir));
|
|
90
|
+
}, [cameraProp]);
|
|
46
91
|
useFrame(function (state, delta) {
|
|
47
92
|
if (!rigidBodyRef ||
|
|
48
93
|
!rigidBodyRef.current ||
|
|
49
94
|
!outerGroupRef ||
|
|
50
95
|
!outerGroupRef.current)
|
|
51
|
-
return
|
|
96
|
+
return;
|
|
52
97
|
cameraProp.delta = delta;
|
|
53
98
|
cameraProp.state = state;
|
|
54
|
-
if (
|
|
55
|
-
orbit
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
normal
|
|
99
|
+
if (!worldContext.cameraBlock) {
|
|
100
|
+
if (mode.control === "orbit") {
|
|
101
|
+
orbit(cameraProp);
|
|
102
|
+
}
|
|
103
|
+
else if (mode.control === "normal") {
|
|
104
|
+
normal(cameraProp);
|
|
105
|
+
}
|
|
106
|
+
detector(cameraProp);
|
|
59
107
|
}
|
|
60
108
|
});
|
|
61
|
-
|
|
109
|
+
// moveTo 함수 정의
|
|
110
|
+
worldContext.moveTo = function (position, target) { return __awaiter(_this, void 0, void 0, function () {
|
|
111
|
+
return __generator(this, function (_a) {
|
|
112
|
+
switch (_a.label) {
|
|
113
|
+
case 0:
|
|
114
|
+
camera.position.copy(position);
|
|
115
|
+
return [4 /*yield*/, Promise.all([
|
|
116
|
+
cameraRef.current.setPosition(position.x, position.y, position.z, true),
|
|
117
|
+
cameraRef.current.setLookAt(position.x, position.y, position.z, target.x, target.y, target.z, true),
|
|
118
|
+
])];
|
|
119
|
+
case 1:
|
|
120
|
+
_a.sent();
|
|
121
|
+
return [2 /*return*/];
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
}); };
|
|
125
|
+
return _jsx(CameraControls, { ref: cameraRef });
|
|
62
126
|
}
|
|
@@ -12,5 +12,5 @@ export function CharacterRef(_a) {
|
|
|
12
12
|
var ref = playCharacterActions({
|
|
13
13
|
groundRay: props.groundRay,
|
|
14
14
|
}).ref;
|
|
15
|
-
return (_jsx(WrapperRef, { props: props, refs: refs, gltf: characterGltf, animationRef: ref, children: _jsx(CharacterCapsuleCollider, { props: props, ref: refs.capsuleColliderRef }) }));
|
|
15
|
+
return (_jsx(WrapperRef, { props: props, refs: refs, gltf: characterGltf, animationRef: ref, name: "character", children: _jsx(CharacterCapsuleCollider, { props: props, ref: refs.capsuleColliderRef }) }));
|
|
16
16
|
}
|
|
@@ -3,6 +3,7 @@ import { ReactNode } from "react";
|
|
|
3
3
|
import { controllerInnerType } from "../../../controller/type";
|
|
4
4
|
export declare const RigidBodyRef: import("react").ForwardRefExoticComponent<{
|
|
5
5
|
children: ReactNode;
|
|
6
|
+
name?: string;
|
|
6
7
|
} & import("react").RefAttributes<RapierRigidBody>>;
|
|
7
8
|
export declare const PassiveRigidBodyRef: import("react").ForwardRefExoticComponent<{
|
|
8
9
|
props: controllerInnerType;
|
|
@@ -13,8 +13,8 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
13
13
|
import { RigidBody } from "@react-three/rapier";
|
|
14
14
|
import { forwardRef } from "react";
|
|
15
15
|
export var RigidBodyRef = forwardRef(function (_a, ref) {
|
|
16
|
-
var children = _a.children;
|
|
17
|
-
return (_jsx(RigidBody, { colliders: false, ref: ref, children: children }));
|
|
16
|
+
var children = _a.children, name = _a.name;
|
|
17
|
+
return (_jsx(RigidBody, { colliders: false, ref: ref, name: name, children: children }));
|
|
18
18
|
});
|
|
19
19
|
export var PassiveRigidBodyRef = forwardRef(function (_a, ref) {
|
|
20
20
|
var props = _a.props, children = _a.children;
|
|
@@ -2,11 +2,12 @@ import { ReactNode, Ref } from "react";
|
|
|
2
2
|
import * as THREE from "three";
|
|
3
3
|
import { controllerInnerType, refsType } from "../../../controller/type";
|
|
4
4
|
import { GLTFResult } from "../../type";
|
|
5
|
-
export declare function WrapperRef({ children, outerChildren, props, refs, gltf, animationRef, }: {
|
|
5
|
+
export declare function WrapperRef({ children, outerChildren, props, refs, gltf, animationRef, name, }: {
|
|
6
6
|
children: ReactNode;
|
|
7
7
|
outerChildren?: ReactNode;
|
|
8
8
|
props: controllerInnerType;
|
|
9
9
|
refs: refsType;
|
|
10
10
|
gltf: GLTFResult;
|
|
11
11
|
animationRef?: Ref<THREE.Object3D<THREE.Object3DEventMap>>;
|
|
12
|
+
name?: string;
|
|
12
13
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -4,6 +4,6 @@ import { OuterGroupRef } from "../common/OuterGroupRef";
|
|
|
4
4
|
import { SlopeRayRef } from "../common/slopeRayRef";
|
|
5
5
|
import { RigidBodyRef } from "./RigidbodyRef";
|
|
6
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, 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] }));
|
|
7
|
+
var children = _a.children, outerChildren = _a.outerChildren, props = _a.props, refs = _a.refs, gltf = _a.gltf, animationRef = _a.animationRef, name = _a.name;
|
|
8
|
+
return (_jsxs(OuterGroupRef, { ref: refs.outerGroupRef, props: props, children: [_jsxs(RigidBodyRef, { ref: refs.rigidBodyRef, name: name, 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
9
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { CuboidCollider } from "@react-three/rapier";
|
|
3
3
|
import { forwardRef, useContext } from "react";
|
|
4
4
|
import { GaesupWorldContext } from "../../../world/context";
|
|
5
5
|
export var VehicleCollider = forwardRef(function (_, ref) {
|
|
6
6
|
var _a = useContext(GaesupWorldContext), collider = _a.vehicleCollider, url = _a.url;
|
|
7
7
|
var vehicleSizeX = collider.vehicleSizeX, vehicleSizeY = collider.vehicleSizeY, vehicleSizeZ = collider.vehicleSizeZ;
|
|
8
|
-
return (_jsx(CuboidCollider, { ref: ref, args: [vehicleSizeX / 2, vehicleSizeY / 2, vehicleSizeZ / 2], position: [0, vehicleSizeY +
|
|
8
|
+
return (_jsx(_Fragment, { children: url.wheelUrl ? (_jsx(CuboidCollider, { ref: ref, args: [vehicleSizeX / 2, vehicleSizeY / 2, vehicleSizeZ / 2], position: [0, vehicleSizeY + collider.wheelSizeY / 2, 0] })) : (_jsx(CuboidCollider, { ref: ref, args: [vehicleSizeX / 2, vehicleSizeY / 2, vehicleSizeZ / 2], position: [0, vehicleSizeY, 0] })) }));
|
|
9
9
|
});
|
|
@@ -4,7 +4,7 @@ import { CylinderCollider, RigidBody, useRevoluteJoint, } from "@react-three/rap
|
|
|
4
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
|
|
7
|
+
var 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]);
|
|
@@ -7,7 +7,7 @@ import { CharacterRef } from "./active/character";
|
|
|
7
7
|
import { VehicleRef } from "./active/vehicle";
|
|
8
8
|
export function GaesupComponent(_a) {
|
|
9
9
|
var props = _a.props, refs = _a.refs;
|
|
10
|
-
var
|
|
10
|
+
var _b = useContext(GaesupWorldContext), mode = _b.mode, activeState = _b.activeState;
|
|
11
11
|
calculation(props);
|
|
12
12
|
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 })] }));
|
|
13
13
|
}
|
|
@@ -69,7 +69,6 @@ export default function initControllerProps(_a) {
|
|
|
69
69
|
intersectObjectMap: {},
|
|
70
70
|
};
|
|
71
71
|
}, []);
|
|
72
|
-
cameraRay.rayCast = new THREE.Raycaster(cameraRay.origin, cameraRay.dir, 0, -context.cameraOption.maxDistance);
|
|
73
72
|
var initRefs = useCallback(function (refs) {
|
|
74
73
|
update({
|
|
75
74
|
refs: __assign({}, refs),
|
|
@@ -44,6 +44,7 @@ export type slopeRayType = Omit<rayType, "parent">;
|
|
|
44
44
|
export type groundRayType = Omit<rayType, "current" | "angle">;
|
|
45
45
|
export type controllerInnerType = {
|
|
46
46
|
isRider?: boolean;
|
|
47
|
+
name?: string;
|
|
47
48
|
slopeRay: slopeRayType;
|
|
48
49
|
groundRay: groundRayType;
|
|
49
50
|
cameraRay: cameraRayType;
|
|
@@ -10,7 +10,7 @@ var __assign = (this && this.__assign) || function () {
|
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
11
|
};
|
|
12
12
|
import { useContext } from "react";
|
|
13
|
-
import { GaesupWorldContext, GaesupWorldDispatchContext, } from "../../world/context
|
|
13
|
+
import { GaesupWorldContext, GaesupWorldDispatchContext, } from "../../world/context";
|
|
14
14
|
export var joyStickBallDefault = {
|
|
15
15
|
top: "50%",
|
|
16
16
|
left: "50%",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RootState } from "@react-three/fiber";
|
|
2
|
-
import { joyStickInnerType } from "../../tools/
|
|
2
|
+
import { joyStickInnerType } from "../../tools/joyStick/type";
|
|
3
3
|
import { activeStateType, modeType } from "../../world/context/type";
|
|
4
4
|
import { calcPropType } from "../type";
|
|
5
5
|
export declare function orbitDirection({ activeState, control, mode, joystick, state, }: {
|
|
@@ -24,13 +24,14 @@ export default function calculation(prop) {
|
|
|
24
24
|
var worldContext = useContext(GaesupWorldContext);
|
|
25
25
|
var controllerContext = useContext(GaesupControllerContext);
|
|
26
26
|
var dispatch = useContext(GaesupWorldDispatchContext);
|
|
27
|
-
var mode = worldContext.mode, activeState = worldContext.activeState;
|
|
27
|
+
var mode = worldContext.mode, activeState = worldContext.activeState, controlBlock = worldContext.controlBlock;
|
|
28
28
|
useEffect(function () {
|
|
29
|
-
var _a;
|
|
30
29
|
var rigidBodyRef = prop.rigidBodyRef;
|
|
31
|
-
if (rigidBodyRef.current)
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
if (rigidBodyRef.current) {
|
|
31
|
+
rigidBodyRef.current.lockRotations(true, true);
|
|
32
|
+
rigidBodyRef.current.setTranslation(activeState.position.clone().add(V3(0, 5, 0)), true);
|
|
33
|
+
}
|
|
34
|
+
}, [mode.type]);
|
|
34
35
|
useFrame(function (state, delta) {
|
|
35
36
|
var rigidBodyRef = prop.rigidBodyRef, outerGroupRef = prop.outerGroupRef, innerGroupRef = prop.innerGroupRef;
|
|
36
37
|
if (!rigidBodyRef ||
|
|
@@ -40,6 +41,8 @@ export default function calculation(prop) {
|
|
|
40
41
|
!innerGroupRef ||
|
|
41
42
|
!innerGroupRef.current)
|
|
42
43
|
return null;
|
|
44
|
+
if (controlBlock)
|
|
45
|
+
return null;
|
|
43
46
|
var calcProp = __assign(__assign({}, prop), { state: state, delta: delta, worldContext: worldContext, controllerContext: controllerContext, dispatch: dispatch, world: world });
|
|
44
47
|
if (mode.type === "vehicle")
|
|
45
48
|
vehicleCalculation(calcProp);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { usePushKey } from "
|
|
2
|
+
import { usePushKey } from "../../hooks/usePushKey";
|
|
3
3
|
import "./style.css";
|
|
4
4
|
export default function GameBoyButton(_a) {
|
|
5
5
|
var tag = _a.tag, value = _a.value, icon = _a.icon, gameboyButtonStyle = _a.gameboyButtonStyle;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useState } from "react";
|
|
3
|
-
import { usePushKey } from "
|
|
3
|
+
import { usePushKey } from "../../hooks/usePushKey";
|
|
4
4
|
import "./style.css";
|
|
5
5
|
export default function GamePadButton(_a) {
|
|
6
6
|
var value = _a.value, name = _a.name, gamePadButtonStyle = _a.gamePadButtonStyle;
|