gaesup-world 0.1.2 → 0.1.3
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/README.md +191 -122
- package/dist/gaesup/camera/control/normal.d.ts +2 -0
- package/dist/gaesup/camera/control/normal.js +8 -1
- package/dist/gaesup/camera/control/orbit.d.ts +1 -1
- package/dist/gaesup/camera/control/orbit.js +3 -2
- package/dist/gaesup/camera/index.js +15 -1
- package/dist/gaesup/component/passive/airplane/index.js +5 -3
- package/dist/gaesup/physics/airplane/direction.js +1 -1
- package/dist/gaesup/physics/airplane/gravity.d.ts +12 -0
- package/dist/gaesup/physics/airplane/gravity.js +16 -10
- package/dist/gaesup/physics/airplane/impulse.d.ts +15 -1
- package/dist/gaesup/physics/airplane/impulse.js +24 -8
- package/dist/gaesup/physics/index.js +4 -3
- package/dist/gaesup/tools/gamePad/GamePadButton.d.ts +3 -2
- package/dist/gaesup/tools/joyStick/index.d.ts +4 -1
- package/dist/gaesup/tools/joyStick/type.d.ts +0 -4
- package/dist/gaesup/tools/jumpPortal/index.d.ts +15 -2
- package/dist/gaesup/tools/jumpPortal/index.js +10 -2
- package/dist/gaesup/tools/miniMap/index.js +1 -1
- package/dist/gaesup/tools/zoomButton/index.d.ts +1 -0
- package/dist/gaesup/tools/zoomButton/index.js +25 -4
- package/dist/index.d.ts +6 -1
- package/dist/index.js +6 -1
- package/package.json +1 -1
- package/dist/gaesup/hooks/index.d.ts +0 -1
- package/dist/gaesup/hooks/index.js +0 -1
package/README.md
CHANGED
|
@@ -3,13 +3,9 @@
|
|
|
3
3
|
[](https://www.npmjs.com/package/gaesup-world)
|
|
4
4
|
[](https://www.npmjs.com/package/gaesup-world)
|
|
5
5
|
|
|
6
|
-
Web 3D Character Controller and World Platform Library
|
|
6
|
+
### Web 3D Character Controller and World Platform Library
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
> click and watch code sandbox example!
|
|
11
|
-
|
|
12
|
-
---
|
|
8
|
+

|
|
13
9
|
|
|
14
10
|
## introduction
|
|
15
11
|
|
|
@@ -109,9 +105,9 @@ This project is distributed under the MIT License.
|
|
|
109
105
|
|
|
110
106
|
---
|
|
111
107
|
|
|
112
|
-
###
|
|
108
|
+
###
|
|
113
109
|
|
|
114
|
-
-
|
|
110
|
+
- ## [PlayerType](##PlayerType)
|
|
115
111
|
|
|
116
112
|
- Character
|
|
117
113
|
- Vehicle
|
|
@@ -119,7 +115,23 @@ This project is distributed under the MIT License.
|
|
|
119
115
|
|
|
120
116
|
- Animation
|
|
121
117
|
|
|
122
|
-
|
|
118
|
+
- ### [Tools](#Tools)
|
|
119
|
+
|
|
120
|
+
- [JoyStick](#JoyStick)
|
|
121
|
+
|
|
122
|
+
* [keyBoardTooltip](#keyBoardTooltip)
|
|
123
|
+
|
|
124
|
+
* [minimap](#MiniMap)
|
|
125
|
+
|
|
126
|
+
* [gameboy](#GameBoy)
|
|
127
|
+
|
|
128
|
+
- [GamePad](#GamePad)
|
|
129
|
+
|
|
130
|
+
- [ZoomButton](#ZoomButton)
|
|
131
|
+
|
|
132
|
+
- [JumpPortal](#JumpPortal)
|
|
133
|
+
|
|
134
|
+
# PlayerType
|
|
123
135
|
|
|
124
136
|
---
|
|
125
137
|
|
|
@@ -144,9 +156,9 @@ This is the character control in Gaesup World.
|
|
|
144
156
|
|
|
145
157
|
## Vehicle
|
|
146
158
|
|
|
147
|
-
This is the vehicle control in Gaesup World. Characters can board the vehicle.
|
|
159
|
+
- This is the vehicle control in Gaesup World. Characters can board the vehicle.
|
|
148
160
|
|
|
149
|
-
|
|
161
|
+
* Possible Camera Types (only orbit type available)
|
|
150
162
|
|
|
151
163
|
| Name | Control | Info |
|
|
152
164
|
| ----- | ------------- | ---------------------------------------------------------------------------- |
|
|
@@ -186,9 +198,7 @@ This is the airplane control in Gaesup World. Characters can board the airplane.
|
|
|
186
198
|
|
|
187
199
|
# Rideable
|
|
188
200
|
|
|
189
|
-
- Rideable objects are objects that can be ridden. They detect collisions and allow the character to board when contact is made. Currently, two types of objects, 'vehicle' and 'airplane', can be ridden.
|
|
190
|
-
|
|
191
|
-

|
|
201
|
+
- Rideable objects are objects that can be ridden. They detect collisions and allow the character to board when contact is made. Currently, two types of objects, 'vehicle' and 'airplane', can be ridden.
|
|
192
202
|
|
|
193
203
|
### (1) Example
|
|
194
204
|
|
|
@@ -284,22 +294,55 @@ export default function App() {
|
|
|
284
294
|
3. **Real-time Interaction:** Leveraging the Rapier physics engine allows for real-time handling of rideable object movements and collision checks, providing a high level of interaction in games or simulations.
|
|
285
295
|
4. **Flexible Customization:** You can customize the appearance and behavior of each rideable object using properties, making it suitable for various game or simulation environments.
|
|
286
296
|
|
|
287
|
-
#
|
|
297
|
+
# GaeSupProps
|
|
298
|
+
|
|
299
|
+
The `GaeSupProps` component is a React component used in a 3D environment. It is designed to represent various types of props or objects within the scene. This component can be used to create props with different types, text labels, and positions for visualization in a 3D space.
|
|
300
|
+
|
|
301
|
+
## Props
|
|
302
|
+
|
|
303
|
+
The `GaeSupProps` component accepts the following props:
|
|
304
|
+
|
|
305
|
+
- `type` (optional): A string specifying the type of the prop. It can be either `"normal"` or `"ground"`. Defaults to `"normal"` if not provided.
|
|
306
|
+
- `text` (optional): A string representing the text label associated with the prop. This label can provide additional information about the prop. If not provided, no label will be displayed.
|
|
307
|
+
- `position` (optional): An array of three numbers `[x, y, z]` specifying the initial position of the prop in the 3D space. If not provided, the prop will be positioned at the origin `[0, 0, 0]`.
|
|
308
|
+
- `children` (required): This prop should contain the 3D content that makes up the visual representation of the prop. It can include any 3D objects or components you want to render within the prop.
|
|
288
309
|
|
|
289
|
-
|
|
310
|
+
### (2) example
|
|
290
311
|
|
|
291
|
-
|
|
312
|
+
- To use the `GaeSupProps` component, you need to import it and include it in your React component tree. Here's an example of how to use it:
|
|
292
313
|
|
|
293
|
-
|
|
314
|
+
```tsx
|
|
315
|
+
import { GaeSupProps } from "./GaeSupProps";
|
|
316
|
+
|
|
317
|
+
function MyScene() {
|
|
318
|
+
return (
|
|
319
|
+
<GaeSupProps type="normal" text="My Prop" position={[3, 1, -2]}>
|
|
320
|
+
{/* 3D content goes here */}
|
|
321
|
+
</GaeSupProps>
|
|
322
|
+
);
|
|
323
|
+
}
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
- In this example, we've created a `GaeSupProps` component with a `"normal"` type, a text label of `"My Prop"`, and a specific position in 3D space.
|
|
327
|
+
|
|
328
|
+
### (3) Behavior
|
|
329
|
+
|
|
330
|
+
- The `GaeSupProps` component also calculates the size and center of the 3D content it contains. It then updates a `minimap` object with this information, which can be useful for tracking the props within the scene.
|
|
294
331
|
|
|
295
|
-
|
|
332
|
+
- Additionally, the component uses the `useEffect` hook to dispatch updates to the context, ensuring that changes to the `minimap` object are reflected in the sce
|
|
296
333
|
|
|
297
|
-
|
|
334
|
+
# Tools
|
|
335
|
+
|
|
336
|
+
- Various tools that assist with character control in GaesupWorld
|
|
298
337
|
|
|
299
|
-
##
|
|
338
|
+
## JoyStick
|
|
300
339
|
|
|
301
340
|
The JoyStick component provides a virtual joystick interface, primarily intended for mobile environments. This component allows you to simulate joystick-like input on mobile devices. Additionally, you can prevent position jitter, which can occur on mobile devices, by using the `scrollBlock` option in the `GaesupWorld` component.
|
|
302
341
|
|
|
342
|
+
| Prop Name | Type | Required | Description | Default Value |
|
|
343
|
+
| ------------------- | --------------- | -------- | --------------------------- | ------------- |
|
|
344
|
+
| `joyStickBallStyle` | object (styles) | Optional | Style for the joystick ball | `undefined` |
|
|
345
|
+
|
|
303
346
|
### Key Features:
|
|
304
347
|
|
|
305
348
|
- **Joystick Interface:** Provides a joystick-like user input interface, suitable for mobile devices.
|
|
@@ -334,9 +377,7 @@ const MyComponent = () => {
|
|
|
334
377
|
};
|
|
335
378
|
```
|
|
336
379
|
|
|
337
|
-
##
|
|
338
|
-
|
|
339
|
-
## 2. KeyBoardToolTip (키보드 툴팁)
|
|
380
|
+
## KeyBoardToolTip
|
|
340
381
|
|
|
341
382
|
The KeyBoardToolTip component is designed to visually represent a keyboard controller interface, providing a visual representation of each key and its associated action.
|
|
342
383
|
|
|
@@ -355,25 +396,11 @@ The KeyBoardToolTip component is designed to visually represent a keyboard contr
|
|
|
355
396
|
|
|
356
397
|
### Example:
|
|
357
398
|
|
|
358
|
-
```
|
|
359
|
-
jsxCopy code
|
|
399
|
+
```tsx
|
|
360
400
|
import { KeyBoardToolTip } from "./KeyBoardToolTip";
|
|
361
401
|
import { GaesupWorldContext } from "../../world/context";
|
|
362
402
|
|
|
363
|
-
const
|
|
364
|
-
const keyBoardToolTipInnerStyle = {
|
|
365
|
-
/* ... */
|
|
366
|
-
};
|
|
367
|
-
const selectedKeyCapStyle = {
|
|
368
|
-
/* ... */
|
|
369
|
-
};
|
|
370
|
-
const notSelectedkeyCapStyle = {
|
|
371
|
-
/* ... */
|
|
372
|
-
};
|
|
373
|
-
const keyCapStyle = {
|
|
374
|
-
/* ... */
|
|
375
|
-
};
|
|
376
|
-
|
|
403
|
+
const App = () => {
|
|
377
404
|
return (
|
|
378
405
|
<GaesupWorld>
|
|
379
406
|
{/* ... */}
|
|
@@ -389,9 +416,41 @@ const MyComponent = () => {
|
|
|
389
416
|
};
|
|
390
417
|
```
|
|
391
418
|
|
|
392
|
-
##
|
|
419
|
+
## MiniMap
|
|
420
|
+
|
|
421
|
+
- The MiniMap component is used to display a small map of the user's location and the surrounding environment within a 3D world.
|
|
393
422
|
|
|
394
|
-
|
|
423
|
+
### (1) props
|
|
424
|
+
|
|
425
|
+
| Prop Name | Type | Required | Description | Default Value |
|
|
426
|
+
| ---------------- | --------------- | -------- | --------------------------------------------- | ------------- |
|
|
427
|
+
| `innerStyle` | object (styles) | Optional | Style for the inner MiniMap container | `undefined` |
|
|
428
|
+
| `textStyle` | object (styles) | Optional | Style for text within the MiniMap | `undefined` |
|
|
429
|
+
| `objectStyle` | object (styles) | Optional | Style for objects within the MiniMap | `undefined` |
|
|
430
|
+
| `avatarStyle` | object (styles) | Optional | Style for avatars within the MiniMap | `undefined` |
|
|
431
|
+
| `scaleStyle` | object (styles) | Optional | Style for the scale control of the MiniMap | `undefined` |
|
|
432
|
+
| `directionStyle` | object (styles) | Optional | Style for direction indicators in the MiniMap | `undefined` |
|
|
433
|
+
| `plusMinusStyle` | object (styles) | Optional | Style for plus/minus controls in the MiniMap | `undefined` |
|
|
434
|
+
|
|
435
|
+
### 2) example
|
|
436
|
+
|
|
437
|
+
```tsx
|
|
438
|
+
import { MiniMap } from "./MiniMap";
|
|
439
|
+
|
|
440
|
+
const App = () => {
|
|
441
|
+
return (
|
|
442
|
+
<GaesupWorld>
|
|
443
|
+
{/* ... */}
|
|
444
|
+
<MiniMap
|
|
445
|
+
minimapStyle={minimapStyle}
|
|
446
|
+
innerStyle={innerStyle}
|
|
447
|
+
// Pass other style properties as needed
|
|
448
|
+
/>
|
|
449
|
+
{/* ... */}
|
|
450
|
+
</GaesupWorld>
|
|
451
|
+
);
|
|
452
|
+
};
|
|
453
|
+
```
|
|
395
454
|
|
|
396
455
|
### Key Features:
|
|
397
456
|
|
|
@@ -406,27 +465,31 @@ The MiniMap component is used to display a small map of the user's location and
|
|
|
406
465
|
2. Customize the appearance using the `minimapStyle`, `innerStyle`, `textStyle`, `objectStyle`, `avatarStyle`, `scaleStyle`, `directionStyle`, and `plusMinusStyle` properties as needed.
|
|
407
466
|
3. The component updates the MiniMap based on the user's current position and direction.
|
|
408
467
|
|
|
409
|
-
|
|
468
|
+
## GameBoy
|
|
410
469
|
|
|
411
|
-
|
|
412
|
-
import { MiniMap } from "./MiniMap";
|
|
470
|
+
- The GameBoy component is a controller interface that emulates GameBoy-like directional buttons. It is primarily intended for mobile usage.
|
|
413
471
|
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
// Define other style properties as needed
|
|
472
|
+
### (1) props
|
|
473
|
+
|
|
474
|
+
| Prop Name | Type | Required | Description | Default Value |
|
|
475
|
+
| -------------------- | --------------- | -------- | ------------------------------------ | ------------- |
|
|
476
|
+
| `gamePadStyle` | object (styles) | Optional | Style for the GamePad container | `undefined` |
|
|
477
|
+
| `gamePadButtonStyle` | object (styles) | Optional | Style for individual GamePad buttons | `undefined` |
|
|
478
|
+
| `label` | string | Optional | Custom label for the buttons | `undefined` |
|
|
422
479
|
|
|
480
|
+
### (2) example
|
|
481
|
+
|
|
482
|
+
```tsx
|
|
483
|
+
import { GameBoy } from "./GameBoy";
|
|
484
|
+
import { GaesupWorldContext } from "../../world/context";
|
|
485
|
+
|
|
486
|
+
const App = () => {
|
|
423
487
|
return (
|
|
424
488
|
<GaesupWorld>
|
|
425
489
|
{/* ... */}
|
|
426
|
-
<
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
// Pass other style properties as needed
|
|
490
|
+
<GameBoy
|
|
491
|
+
gameboyStyle={gameboyStyle}
|
|
492
|
+
gameboyButtonStyle={gameboyButtonStyle}
|
|
430
493
|
/>
|
|
431
494
|
{/* ... */}
|
|
432
495
|
</GaesupWorld>
|
|
@@ -434,10 +497,6 @@ const MyComponent = () => {
|
|
|
434
497
|
};
|
|
435
498
|
```
|
|
436
499
|
|
|
437
|
-
## 4. GameBoy
|
|
438
|
-
|
|
439
|
-
- The GameBoy component is a controller interface that emulates GameBoy-like directional buttons. It is primarily intended for mobile usage.
|
|
440
|
-
|
|
441
500
|
### Key Features:
|
|
442
501
|
|
|
443
502
|
- **Direction Buttons:** Implements buttons for directional input (forward, backward, left, right) based on the `GameBoyDirections` array.
|
|
@@ -452,108 +511,118 @@ To use the `GameBoy` component:
|
|
|
452
511
|
2. Customize the appearance by defining styles in the `gameboyStyle` and `gameboyButtonStyle` properties.
|
|
453
512
|
3. The component renders buttons based on the `GameBoyDirections` array.
|
|
454
513
|
|
|
455
|
-
|
|
514
|
+
## GamePad
|
|
515
|
+
|
|
516
|
+
- The GamePad component provides a customizable controller interface that supports various controller modes, such as joysticks and GameBoys, making it versatile for different input scenarios.
|
|
517
|
+
|
|
518
|
+
### (1) props
|
|
519
|
+
|
|
520
|
+
| Prop Name | Type | Required | Description | Default Value |
|
|
521
|
+
| -------------------- | --------------- | -------- | ------------------------------------ | ------------- |
|
|
522
|
+
| `gamePadStyle` | object (styles) | Optional | Style for the GamePad container | `undefined` |
|
|
523
|
+
| `gamePadButtonStyle` | object (styles) | Optional | Style for individual GamePad buttons | `undefined` |
|
|
524
|
+
| `label` | string | Optional | Custom label for the buttons | `undefined` |
|
|
525
|
+
|
|
526
|
+
### (2) example
|
|
456
527
|
|
|
457
528
|
```tsx
|
|
458
|
-
import {
|
|
529
|
+
import { GamePad } from "./GamePad";
|
|
459
530
|
import { GaesupWorldContext } from "../../world/context";
|
|
460
531
|
|
|
461
|
-
const
|
|
462
|
-
// Define custom styles
|
|
463
|
-
const gameboyStyle = {
|
|
464
|
-
/* ... */
|
|
465
|
-
};
|
|
466
|
-
const gameboyButtonStyle = {
|
|
467
|
-
/* ... */
|
|
468
|
-
};
|
|
469
|
-
|
|
532
|
+
const App = () => {
|
|
470
533
|
return (
|
|
471
|
-
<
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
534
|
+
<GaesupWorld>
|
|
535
|
+
{/* ... */}
|
|
536
|
+
<GamePad
|
|
537
|
+
gamePadStyle={gamePadStyle}
|
|
538
|
+
gamePadButtonStyle={gamePadButtonStyle}
|
|
539
|
+
/>
|
|
540
|
+
{/* ... */}
|
|
541
|
+
</GaesupWorld>
|
|
475
542
|
);
|
|
476
543
|
};
|
|
477
544
|
```
|
|
478
545
|
|
|
479
|
-
## 5. GamePad
|
|
480
|
-
|
|
481
|
-
- The GamePad component provides a customizable controller interface that supports various controller modes, such as joysticks and GameBoys, making it versatile for different input scenarios.
|
|
482
|
-
|
|
483
546
|
### Key Features:
|
|
484
547
|
|
|
485
548
|
- **Dynamic Button Rendering:** Dynamically generates buttons based on the `control` object in the `GaesupWorldContext`.
|
|
486
549
|
- **Universal Usage:** Compatible with various controller modes like joysticks and GameBoys.
|
|
487
550
|
- **Custom Styling:** Allows customization of the GamePad's appearance using the `gamePadStyle` and `gamePadButtonStyle` properties.
|
|
488
551
|
|
|
489
|
-
### Props:
|
|
490
|
-
|
|
491
|
-
- `gamePadStyle`: Style of the GamePad container (`React.CSSProperties` object).
|
|
492
|
-
- `gamePadButtonStyle`: Style of individual buttons (`React.CSSProperties` object).
|
|
493
|
-
- `label`: Custom label for the buttons.
|
|
494
|
-
|
|
495
552
|
### How to Use:
|
|
496
553
|
|
|
497
554
|
1. Include the `GamePad` component within your component tree.
|
|
498
555
|
2. Customize the appearance using the `gamePadStyle` and `gamePadButtonStyle` properties.
|
|
499
556
|
3. The component dynamically renders buttons based on the `control` mode.
|
|
500
557
|
|
|
501
|
-
|
|
558
|
+
## ZoomButton
|
|
502
559
|
|
|
503
|
-
|
|
504
|
-
jsxCopy code
|
|
505
|
-
import { GamePad } from "./GamePad";
|
|
506
|
-
import { GaesupWorldContext } from "../../world/context";
|
|
560
|
+
- The ZoomButton component is used to move the camera to a specific location and control the camera's zoom, primarily used for zooming to a target.
|
|
507
561
|
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
562
|
+
### (1) props
|
|
563
|
+
|
|
564
|
+
| Prop Name | Type | Required | Description | Default Value |
|
|
565
|
+
| ----------------- | --------------- | -------- | ---------------------------------------------------------- | ------------- |
|
|
566
|
+
| `position` | THREE.Vector3 | Required | Target position for the camera to move to | None |
|
|
567
|
+
| `children` | React.ReactNode | Optional | React nodes to render within the button | `undefined` |
|
|
568
|
+
| `target` | THREE.Vector3 | Optional | Target position for the camera to look at | `undefined` |
|
|
569
|
+
| `keepBlocking` | boolean | Optional | Determines whether to keep blocking while camera is moving | `undefined` |
|
|
570
|
+
| `zoomButtonStyle` | object (styles) | Optional | Style for the ZoomButton component | `undefined` |
|
|
571
|
+
|
|
572
|
+
### (2) example
|
|
515
573
|
|
|
574
|
+
```tsx
|
|
575
|
+
import { ZoomButton } from "./ZoomButton";
|
|
576
|
+
import * as THREE from "three";
|
|
577
|
+
|
|
578
|
+
const App = () => {
|
|
516
579
|
return (
|
|
517
|
-
<
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
580
|
+
<GaesupWorld>
|
|
581
|
+
{/* ... */}
|
|
582
|
+
<ZoomButton position={new THREE.Vector3(0, 0, 5)}>{childern}</ZoomButton>
|
|
583
|
+
{/* ... */}
|
|
584
|
+
</GaesupWorld>
|
|
521
585
|
);
|
|
522
586
|
};
|
|
523
587
|
```
|
|
524
588
|
|
|
525
|
-
|
|
589
|
+
### (3) How to Use
|
|
526
590
|
|
|
527
|
-
|
|
591
|
+
1. Place the `ZoomButton` component in your component tree at the desired location.
|
|
592
|
+
2. Define the `position` prop to specify the location the camera should move to.
|
|
593
|
+
3. When the button is clicked, the camera will move to the specified position.
|
|
528
594
|
|
|
529
|
-
|
|
595
|
+
## JumpPortal
|
|
530
596
|
|
|
531
|
-
- `
|
|
532
|
-
- `children`: (Optional) React nodes to render within the button.
|
|
533
|
-
- `target`: (Optional) The target position the camera will look at (`THREE.Vector3` object).
|
|
534
|
-
- `keepBlocking`: (Optional) Determines whether to keep the blocking state while the camera is moving.
|
|
535
|
-
- `zoomButtonStyle`: (Optional) Style for the button (`React.CSSProperties` object).
|
|
597
|
+
- The `JumpPortal` component represents a clickable portal that allows users to teleport to a specified location within a 3D world. This component can be used to create interactive teleportation points in your application.
|
|
536
598
|
|
|
537
|
-
###
|
|
599
|
+
### (1) props
|
|
538
600
|
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
601
|
+
| Prop Name | Type | Required | Description | Default Value |
|
|
602
|
+
| ----------------- | ------------- | -------- | ----------------------------------------------------------- | ------------- |
|
|
603
|
+
| `text` | string | Optional | The text to display on the portal. | `undefined` |
|
|
604
|
+
| `position` | THREE.Vector3 | Required | The target position to teleport to using a `THREE.Vector3`. | None |
|
|
605
|
+
| `jumpPortalStyle` | CSSProperties | Optional | CSS styles for customizing the appearance of the portal. | `undefined` |
|
|
542
606
|
|
|
543
|
-
###
|
|
607
|
+
### (2) example
|
|
608
|
+
|
|
609
|
+
- To use the `JumpPortal` component, you can import it and include it in your React application as follows:
|
|
544
610
|
|
|
545
611
|
```tsx
|
|
546
|
-
|
|
547
|
-
import { ZoomButton } from "./ZoomButton";
|
|
612
|
+
import { JumpPortal } from "./JumpPortal";
|
|
548
613
|
import * as THREE from "three";
|
|
549
614
|
|
|
550
615
|
const App = () => {
|
|
551
616
|
return (
|
|
552
|
-
<
|
|
553
|
-
|
|
554
|
-
|
|
617
|
+
<GaesupWorld>
|
|
618
|
+
{/* ... */}
|
|
619
|
+
<JumpPortal
|
|
620
|
+
text="Teleport"
|
|
621
|
+
position={new THREE.Vector3(10, 0, 5)}
|
|
622
|
+
jumpPortalStyle={{ backgroundColor: "blue", color: "white" }}
|
|
623
|
+
/>
|
|
624
|
+
{/* ... */}
|
|
625
|
+
</GaesupWorld>
|
|
555
626
|
);
|
|
556
627
|
};
|
|
557
628
|
```
|
|
558
|
-
|
|
559
|
-
##
|
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
import { cameraPropType } from "../../physics/type";
|
|
2
|
+
import { activeStateType, cameraOptionType } from "../../world/context/type";
|
|
3
|
+
export declare const makeNormalCameraPosition: (activeState: activeStateType, cameraOption: cameraOptionType) => import("three").Vector3;
|
|
2
4
|
export default function normal(prop: cameraPropType): void;
|
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
import { V3 } from "../../utils/vector";
|
|
2
|
+
export var makeNormalCameraPosition = function (activeState, cameraOption) {
|
|
3
|
+
var YDistance = cameraOption.YDistance, ZDistance = cameraOption.ZDistance;
|
|
4
|
+
var cameraPosition = activeState.position
|
|
5
|
+
.clone()
|
|
6
|
+
.add(V3(0, YDistance, ZDistance));
|
|
7
|
+
return cameraPosition;
|
|
8
|
+
};
|
|
2
9
|
export default function normal(prop) {
|
|
3
10
|
var state = prop.state, _a = prop.worldContext, activeState = _a.activeState, cameraOption = _a.cameraOption;
|
|
4
11
|
if (!state || !state.camera)
|
|
5
12
|
return;
|
|
6
13
|
var cameraPosition = activeState.position
|
|
7
14
|
.clone()
|
|
8
|
-
.add(V3(0, cameraOption.YDistance, cameraOption.
|
|
15
|
+
.add(V3(0, cameraOption.YDistance, cameraOption.ZDistance));
|
|
9
16
|
state.camera.position.lerp(cameraPosition, 1);
|
|
10
17
|
state.camera.lookAt(activeState.position.clone());
|
|
11
18
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { cameraPropType } from "../../physics/type";
|
|
2
2
|
import { activeStateType, cameraOptionType } from "../../world/context/type";
|
|
3
|
-
export declare const
|
|
3
|
+
export declare const makeOrbitCameraPosition: (activeState: activeStateType, cameraOption: cameraOptionType) => import("three").Vector3;
|
|
4
4
|
export default function orbit(prop: cameraPropType): void;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { quat } from "@react-three/rapier";
|
|
2
2
|
import { V3 } from "../../utils/vector";
|
|
3
|
-
export var
|
|
3
|
+
export var makeOrbitCameraPosition = function (activeState, cameraOption) {
|
|
4
4
|
var XDistance = cameraOption.XDistance, YDistance = cameraOption.YDistance, ZDistance = cameraOption.ZDistance;
|
|
5
5
|
var cameraPosition = activeState.position.clone().add(V3(Math.sin(activeState.euler.y), 1, Math.cos(activeState.euler.y))
|
|
6
6
|
.normalize()
|
|
@@ -12,10 +12,11 @@ export default function orbit(prop) {
|
|
|
12
12
|
var state = prop.state, _a = prop.worldContext, activeState = _a.activeState, cameraOption = _a.cameraOption;
|
|
13
13
|
if (!state || !state.camera)
|
|
14
14
|
return;
|
|
15
|
-
var cameraPosition =
|
|
15
|
+
var cameraPosition = makeOrbitCameraPosition(activeState, cameraOption);
|
|
16
16
|
state.camera.position.lerp(cameraPosition, 1);
|
|
17
17
|
state.camera.quaternion.copy(activeState.quat
|
|
18
18
|
.clone()
|
|
19
19
|
.multiply(quat().setFromAxisAngle(V3(0, 1, 0), Math.PI)));
|
|
20
|
+
state.camera.rotation.copy(activeState.euler);
|
|
20
21
|
state.camera.lookAt(activeState.position.clone());
|
|
21
22
|
}
|
|
@@ -105,6 +105,7 @@ export default function Camera(_a) {
|
|
|
105
105
|
}
|
|
106
106
|
detector(cameraProp);
|
|
107
107
|
}
|
|
108
|
+
console.log(cameraProp.worldContext.cameraOption.XDistance, cameraProp.worldContext.cameraOption.YDistance, cameraProp.worldContext.cameraOption.ZDistance);
|
|
108
109
|
});
|
|
109
110
|
// moveTo 함수 정의
|
|
110
111
|
worldContext.moveTo = function (position, target) { return __awaiter(_this, void 0, void 0, function () {
|
|
@@ -112,13 +113,26 @@ export default function Camera(_a) {
|
|
|
112
113
|
switch (_a.label) {
|
|
113
114
|
case 0:
|
|
114
115
|
camera.position.copy(position);
|
|
116
|
+
if (!(mode.control === "orbit")) return [3 /*break*/, 2];
|
|
115
117
|
return [4 /*yield*/, Promise.all([
|
|
116
118
|
cameraRef.current.setPosition(position.x, position.y, position.z, true),
|
|
119
|
+
camera.rotation.copy(worldContext.activeState.euler),
|
|
117
120
|
cameraRef.current.setLookAt(position.x, position.y, position.z, target.x, target.y, target.z, true),
|
|
118
121
|
])];
|
|
119
122
|
case 1:
|
|
120
123
|
_a.sent();
|
|
121
|
-
return [
|
|
124
|
+
return [3 /*break*/, 4];
|
|
125
|
+
case 2:
|
|
126
|
+
if (!(mode.control === "normal")) return [3 /*break*/, 4];
|
|
127
|
+
return [4 /*yield*/, Promise.all([
|
|
128
|
+
cameraRef.current.setPosition(0, position.y, position.z, true),
|
|
129
|
+
camera.rotation.copy(worldContext.activeState.euler),
|
|
130
|
+
cameraRef.current.setLookAt(0, position.y, position.z, target.x, target.y, target.z, true),
|
|
131
|
+
])];
|
|
132
|
+
case 3:
|
|
133
|
+
_a.sent();
|
|
134
|
+
_a.label = 4;
|
|
135
|
+
case 4: return [2 /*return*/];
|
|
122
136
|
}
|
|
123
137
|
});
|
|
124
138
|
}); };
|
|
@@ -33,9 +33,11 @@ export function PassiveAirplane(props) {
|
|
|
33
33
|
.setFromEuler(innerGroupRef.current.rotation.clone())
|
|
34
34
|
.slerp(quat().setFromEuler(_euler), 0.2));
|
|
35
35
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
if (rigidBodyRef && rigidBodyRef.current) {
|
|
37
|
+
rigidBodyRef.current.setGravityScale(props.position.y < 10
|
|
38
|
+
? ((1 - 0.1) / (0 - 10)) * props.position.y + 1
|
|
39
|
+
: 0.1, false);
|
|
40
|
+
}
|
|
39
41
|
});
|
|
40
42
|
return (_jsxs(OuterGroupRef, { ref: refs.outerGroupRef, children: [props.children, airplaneUrl && (_jsxs(RigidBodyRef, { ref: refs.rigidBodyRef, position: position, rotation: euler, onCollisionEnter: props.onCollisionEnter, children: [_jsx(InnerGroupRef, { currentAnimation: currentAnimation, ref: refs.innerGroupRef, url: airplaneUrl }), _jsx(CuboidCollider, { ref: colliderRef, args: [airplaneSize.x / 2, airplaneSize.y / 2, airplaneSize.z / 2], position: [0, airplaneSize.y / 2, 0] })] }))] }));
|
|
41
43
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { quat } from "@react-three/rapier";
|
|
2
2
|
import { V3 } from "../../utils/vector";
|
|
3
3
|
export default function direction(prop) {
|
|
4
|
-
var
|
|
4
|
+
var innerGroupRef = prop.innerGroupRef, _a = prop.worldContext, joystick = _a.joystick, activeState = _a.activeState, control = _a.control, mode = _a.mode, airplane = prop.controllerContext.airplane;
|
|
5
5
|
var forward = control.forward, backward = control.backward, leftward = control.leftward, rightward = control.rightward, shift = control.shift, space = control.space;
|
|
6
6
|
var angleDelta = airplane.angleDelta, maxAngle = airplane.maxAngle, accelRatio = airplane.accelRatio;
|
|
7
7
|
var boost = 0;
|
|
@@ -1,2 +1,14 @@
|
|
|
1
1
|
import { calcPropType } from "../type";
|
|
2
|
+
/**
|
|
3
|
+
* This function calculates and sets gravity.
|
|
4
|
+
*
|
|
5
|
+
* @param {calcPropType} prop - An object containing properties necessary for gravity calculation.
|
|
6
|
+
* @param {object} prop.rigidBodyRef - A reference to the physical object where gravity is being set.
|
|
7
|
+
* @param {object} prop.worldContext - An object representing the current state of the game world.
|
|
8
|
+
* @param {number} prop.worldContext.activeState.position.y - The current Y-coordinate position.
|
|
9
|
+
*
|
|
10
|
+
* Gravity is calculated based on altitude and buoyancy. When altitude is less than 10, gravity is calculated as follows:
|
|
11
|
+
* Gravity = ((1 - buoyancy) / (0 - 10)) * current Y-coordinate + buoyancy
|
|
12
|
+
* Otherwise, gravity is set to 0.1.
|
|
13
|
+
*/
|
|
2
14
|
export default function gravity(prop: calcPropType): void;
|
|
@@ -1,12 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This function calculates and sets gravity.
|
|
3
|
+
*
|
|
4
|
+
* @param {calcPropType} prop - An object containing properties necessary for gravity calculation.
|
|
5
|
+
* @param {object} prop.rigidBodyRef - A reference to the physical object where gravity is being set.
|
|
6
|
+
* @param {object} prop.worldContext - An object representing the current state of the game world.
|
|
7
|
+
* @param {number} prop.worldContext.activeState.position.y - The current Y-coordinate position.
|
|
8
|
+
*
|
|
9
|
+
* Gravity is calculated based on altitude and buoyancy. When altitude is less than 10, gravity is calculated as follows:
|
|
10
|
+
* Gravity = ((1 - buoyancy) / (0 - 10)) * current Y-coordinate + buoyancy
|
|
11
|
+
* Otherwise, gravity is set to 0.1.
|
|
12
|
+
*/
|
|
1
13
|
export default function gravity(prop) {
|
|
2
|
-
var rigidBodyRef = prop.rigidBodyRef,
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
rigidBodyRef.current.setGravityScale(airplaneCollider.gravity, false);
|
|
7
|
-
}
|
|
8
|
-
else {
|
|
9
|
-
airplaneCollider.gravity = buoyancy;
|
|
10
|
-
rigidBodyRef.current.setGravityScale(airplaneCollider.gravity, false);
|
|
11
|
-
}
|
|
14
|
+
var rigidBodyRef = prop.rigidBodyRef, activeState = prop.worldContext.activeState;
|
|
15
|
+
rigidBodyRef.current.setGravityScale(activeState.position.y < 10
|
|
16
|
+
? ((1 - 0.1) / (0 - 10)) * activeState.position.y + 1
|
|
17
|
+
: 0.1, false);
|
|
12
18
|
}
|
|
@@ -1,2 +1,16 @@
|
|
|
1
1
|
import { calcPropType } from "../type";
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* This function applies an impulse to a rigid body in the game world.
|
|
4
|
+
*
|
|
5
|
+
* @param {calcPropType} prop - An object containing properties necessary for applying the impulse.
|
|
6
|
+
* @param {object} prop.rigidBodyRef - A reference to the rigid body to which the impulse is applied.
|
|
7
|
+
* @param {object} prop.worldContext - An object representing the current state of the game world.
|
|
8
|
+
* @param {object} prop.controllerContext - An object containing controller-specific context data.
|
|
9
|
+
* @param {object} prop.controllerContext.airplane - An object representing the airplane controller context.
|
|
10
|
+
* @param {number} prop.controllerContext.airplane.maxSpeed - The maximum speed of the airplane.
|
|
11
|
+
*
|
|
12
|
+
* This function calculates the current speed of the rigid body and compares it to the maximum speed.
|
|
13
|
+
* If the current speed is greater than the maximum speed, no impulse is applied.
|
|
14
|
+
* Otherwise, an impulse is applied to the rigid body in the direction specified by `activeState.direction`.
|
|
15
|
+
*/
|
|
16
|
+
export default function impulse(prop: calcPropType): void;
|
|
@@ -1,15 +1,31 @@
|
|
|
1
1
|
import { vec3 } from "@react-three/rapier";
|
|
2
|
+
/**
|
|
3
|
+
* This function applies an impulse to a rigid body in the game world.
|
|
4
|
+
*
|
|
5
|
+
* @param {calcPropType} prop - An object containing properties necessary for applying the impulse.
|
|
6
|
+
* @param {object} prop.rigidBodyRef - A reference to the rigid body to which the impulse is applied.
|
|
7
|
+
* @param {object} prop.worldContext - An object representing the current state of the game world.
|
|
8
|
+
* @param {object} prop.controllerContext - An object containing controller-specific context data.
|
|
9
|
+
* @param {object} prop.controllerContext.airplane - An object representing the airplane controller context.
|
|
10
|
+
* @param {number} prop.controllerContext.airplane.maxSpeed - The maximum speed of the airplane.
|
|
11
|
+
*
|
|
12
|
+
* This function calculates the current speed of the rigid body and compares it to the maximum speed.
|
|
13
|
+
* If the current speed is greater than the maximum speed, no impulse is applied.
|
|
14
|
+
* Otherwise, an impulse is applied to the rigid body in the direction specified by `activeState.direction`.
|
|
15
|
+
*/
|
|
2
16
|
export default function impulse(prop) {
|
|
3
17
|
var rigidBodyRef = prop.rigidBodyRef, activeState = prop.worldContext.activeState, airplane = prop.controllerContext.airplane;
|
|
4
18
|
var maxSpeed = airplane.maxSpeed;
|
|
5
19
|
var velocity = rigidBodyRef.current.linvel();
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
20
|
+
// a = v / t (t = 1) (approximate calculation)
|
|
21
|
+
var V = vec3(velocity).length();
|
|
22
|
+
if (V < maxSpeed) {
|
|
23
|
+
var M = rigidBodyRef.current.mass();
|
|
24
|
+
// impulse = mass * velocity
|
|
25
|
+
rigidBodyRef.current.applyImpulse(vec3({
|
|
26
|
+
x: activeState.direction.x,
|
|
27
|
+
y: activeState.direction.y,
|
|
28
|
+
z: activeState.direction.z,
|
|
29
|
+
}).multiplyScalar(M), false);
|
|
9
30
|
}
|
|
10
|
-
rigidBodyRef.current.applyImpulse(vec3({
|
|
11
|
-
x: activeState.direction.x,
|
|
12
|
-
y: activeState.direction.y,
|
|
13
|
-
z: activeState.direction.z,
|
|
14
|
-
}), false);
|
|
15
31
|
}
|
|
@@ -26,9 +26,10 @@ export default function calculation(prop) {
|
|
|
26
26
|
var dispatch = useContext(GaesupWorldDispatchContext);
|
|
27
27
|
var mode = worldContext.mode, activeState = worldContext.activeState, controlBlock = worldContext.controlBlock;
|
|
28
28
|
useEffect(function () {
|
|
29
|
-
var rigidBodyRef = prop.rigidBodyRef;
|
|
30
|
-
if (rigidBodyRef.current) {
|
|
31
|
-
rigidBodyRef.current.lockRotations(true, true);
|
|
29
|
+
var rigidBodyRef = prop.rigidBodyRef, innerGroupRef = prop.innerGroupRef;
|
|
30
|
+
if (rigidBodyRef.current && innerGroupRef.current) {
|
|
31
|
+
// rigidBodyRef.current.lockRotations(true, true);
|
|
32
|
+
activeState.euler.set(0, 0, 0);
|
|
32
33
|
rigidBodyRef.current.setTranslation(activeState.position.clone().add(V3(0, 2, 0)), true);
|
|
33
34
|
}
|
|
34
35
|
}, [mode.type]);
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { CSSProperties } from "react";
|
|
2
2
|
import "./style.css";
|
|
3
|
-
export
|
|
3
|
+
export type gamePadButtonType = {
|
|
4
4
|
value: string;
|
|
5
5
|
name: string;
|
|
6
6
|
gamePadButtonStyle: CSSProperties;
|
|
7
|
-
}
|
|
7
|
+
};
|
|
8
|
+
export default function GamePadButton({ value, name, gamePadButtonStyle, }: gamePadButtonType): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { CSSProperties } from "react";
|
|
1
2
|
import "./style.css";
|
|
2
|
-
|
|
3
|
+
export type joyStickType = {
|
|
4
|
+
[key in "joyStickBallStyle" | "joyStickStyle" | "joyBallStyle"]?: CSSProperties;
|
|
5
|
+
};
|
|
3
6
|
export declare function JoyStick(props: joyStickType): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { CSSProperties } from "react";
|
|
2
1
|
export type joyStickBallType = {
|
|
3
2
|
left: string;
|
|
4
3
|
top: string;
|
|
@@ -18,6 +17,3 @@ export type joyStickInnerType = {
|
|
|
18
17
|
joyStickBall?: joyStickBallType;
|
|
19
18
|
joyStickOrigin?: joyStickOriginType;
|
|
20
19
|
};
|
|
21
|
-
export type joyStickType = {
|
|
22
|
-
[key in "joyStickBallStyle" | "joyStickStyle" | "joyBallStyle"]?: CSSProperties;
|
|
23
|
-
};
|
|
@@ -1,3 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CSSProperties } from "react";
|
|
2
2
|
import "./style.css";
|
|
3
|
-
export
|
|
3
|
+
export type JumpPortalType = {
|
|
4
|
+
text?: string;
|
|
5
|
+
position: THREE.Vector3;
|
|
6
|
+
jumpPortalStyle?: CSSProperties;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* JumpPortal component represents a clickable portal that teleports the user to a specified location.
|
|
10
|
+
*
|
|
11
|
+
* @param {JumpPortalType} props - The props for the JumpPortal component.
|
|
12
|
+
* @param {string} props.text - (Optional) The text to display on the portal.
|
|
13
|
+
* @param {THREE.Vector3} props.position - The target position to teleport to.
|
|
14
|
+
* @param {CSSProperties} props.jumpPortalStyle - (Optional) CSS styles for the JumpPortal component.
|
|
15
|
+
*/
|
|
16
|
+
export declare function JumpPortal({ text, position, jumpPortalStyle, }: JumpPortalType): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useTeleport } from "../../hooks/useTeleport";
|
|
3
3
|
import "./style.css";
|
|
4
|
+
/**
|
|
5
|
+
* JumpPortal component represents a clickable portal that teleports the user to a specified location.
|
|
6
|
+
*
|
|
7
|
+
* @param {JumpPortalType} props - The props for the JumpPortal component.
|
|
8
|
+
* @param {string} props.text - (Optional) The text to display on the portal.
|
|
9
|
+
* @param {THREE.Vector3} props.position - The target position to teleport to.
|
|
10
|
+
* @param {CSSProperties} props.jumpPortalStyle - (Optional) CSS styles for the JumpPortal component.
|
|
11
|
+
*/
|
|
4
12
|
export function JumpPortal(_a) {
|
|
5
|
-
var text = _a.text, position = _a.position,
|
|
13
|
+
var text = _a.text, position = _a.position, jumpPortalStyle = _a.jumpPortalStyle;
|
|
6
14
|
var Teleport = useTeleport().Teleport;
|
|
7
15
|
return (_jsx("div", { className: "jumpPortal", onClick: function () {
|
|
8
16
|
Teleport(position);
|
|
9
|
-
}, style:
|
|
17
|
+
}, style: jumpPortalStyle, children: text }));
|
|
10
18
|
}
|
|
@@ -19,7 +19,7 @@ import "./style.css";
|
|
|
19
19
|
export function MiniMap(props) {
|
|
20
20
|
var _a = useContext(GaesupWorldContext), minimap = _a.minimap, activeState = _a.activeState, mode = _a.mode;
|
|
21
21
|
var _b = useState(props.scale || minimapDefault.scale), scale = _b[0], setscale = _b[1];
|
|
22
|
-
var
|
|
22
|
+
var innerStyle = props.innerStyle, textStyle = props.textStyle, objectStyle = props.objectStyle, avatarStyle = props.avatarStyle, scaleStyle = props.scaleStyle, directionStyle = props.directionStyle, plusMinusStyle = props.plusMinusStyle;
|
|
23
23
|
var upscale = useCallback(function () {
|
|
24
24
|
var max = props.maxScale || minimapDefault.maxScale;
|
|
25
25
|
setscale(function (scale) { return Math.min(max, scale + 0.1); });
|
|
@@ -13,5 +13,6 @@ export declare function useZoom(): {
|
|
|
13
13
|
closeCamera: (position: THREE.Vector3) => Promise<void>;
|
|
14
14
|
isZoom: boolean;
|
|
15
15
|
setIsZoom: import("react").Dispatch<import("react").SetStateAction<boolean>>;
|
|
16
|
+
moveToCamera: () => Promise<void>;
|
|
16
17
|
};
|
|
17
18
|
export declare function ZoomButton(props: zoomButtonPropsType): import("react/jsx-runtime").JSX.Element;
|
|
@@ -47,12 +47,13 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
47
47
|
};
|
|
48
48
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
49
49
|
import { useContext, useState } from "react";
|
|
50
|
-
import {
|
|
51
|
-
import {
|
|
50
|
+
import { makeNormalCameraPosition } from "../../camera/control/normal";
|
|
51
|
+
import { makeOrbitCameraPosition } from "../../camera/control/orbit";
|
|
52
|
+
import { GaesupWorldContext, GaesupWorldDispatchContext, } from "../../world/context/index";
|
|
52
53
|
import "./style.css";
|
|
53
54
|
export function useZoom() {
|
|
54
55
|
var _this = this;
|
|
55
|
-
var _a = useContext(GaesupWorldContext), moveTo = _a.moveTo, activeState = _a.activeState, cameraOption = _a.cameraOption;
|
|
56
|
+
var _a = useContext(GaesupWorldContext), moveTo = _a.moveTo, activeState = _a.activeState, cameraOption = _a.cameraOption, mode = _a.mode;
|
|
56
57
|
var dispatch = useContext(GaesupWorldDispatchContext);
|
|
57
58
|
var _b = useState(true), isZoom = _b[0], setIsZoom = _b[1];
|
|
58
59
|
var closeCamera = function (position) { return __awaiter(_this, void 0, void 0, function () {
|
|
@@ -81,6 +82,25 @@ export function useZoom() {
|
|
|
81
82
|
return [2 /*return*/];
|
|
82
83
|
});
|
|
83
84
|
}); };
|
|
85
|
+
var moveToCamera = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
86
|
+
return __generator(this, function (_a) {
|
|
87
|
+
switch (_a.label) {
|
|
88
|
+
case 0:
|
|
89
|
+
if (!(mode.control === "orbit" && moveTo)) return [3 /*break*/, 2];
|
|
90
|
+
return [4 /*yield*/, moveTo(makeOrbitCameraPosition(activeState, cameraOption), activeState.position)];
|
|
91
|
+
case 1:
|
|
92
|
+
_a.sent();
|
|
93
|
+
return [3 /*break*/, 4];
|
|
94
|
+
case 2:
|
|
95
|
+
if (!(mode.control === "normal" && moveTo)) return [3 /*break*/, 4];
|
|
96
|
+
return [4 /*yield*/, moveTo(makeNormalCameraPosition(activeState, cameraOption), activeState.position)];
|
|
97
|
+
case 3:
|
|
98
|
+
_a.sent();
|
|
99
|
+
_a.label = 4;
|
|
100
|
+
case 4: return [2 /*return*/];
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
}); };
|
|
84
104
|
var setZoom = function (position, isZoom) { return __awaiter(_this, void 0, void 0, function () {
|
|
85
105
|
return __generator(this, function (_a) {
|
|
86
106
|
switch (_a.label) {
|
|
@@ -89,7 +109,7 @@ export function useZoom() {
|
|
|
89
109
|
return [4 /*yield*/, closeCamera(position)];
|
|
90
110
|
case 1:
|
|
91
111
|
_a.sent();
|
|
92
|
-
return [4 /*yield*/,
|
|
112
|
+
return [4 /*yield*/, moveToCamera()];
|
|
93
113
|
case 2:
|
|
94
114
|
_a.sent();
|
|
95
115
|
return [4 /*yield*/, openCamera()];
|
|
@@ -105,6 +125,7 @@ export function useZoom() {
|
|
|
105
125
|
closeCamera: closeCamera,
|
|
106
126
|
isZoom: isZoom,
|
|
107
127
|
setIsZoom: setIsZoom,
|
|
128
|
+
moveToCamera: moveToCamera,
|
|
108
129
|
};
|
|
109
130
|
}
|
|
110
131
|
export function ZoomButton(props) {
|
package/dist/index.d.ts
CHANGED
|
@@ -6,7 +6,6 @@ export { PassiveCharacter } from "./gaesup/component/passive/character";
|
|
|
6
6
|
export { PassiveVehicle } from "./gaesup/component/passive/vehicle";
|
|
7
7
|
export { GaesupController } from "./gaesup/controller";
|
|
8
8
|
export { GaeSupProps } from "./gaesup/gaesupProps";
|
|
9
|
-
export { useGaesupController } from "./gaesup/hooks";
|
|
10
9
|
export { GameBoy } from "./gaesup/tools/gameBoy";
|
|
11
10
|
export { GamePad } from "./gaesup/tools/gamePad";
|
|
12
11
|
export { JoyStick } from "./gaesup/tools/joyStick";
|
|
@@ -17,3 +16,9 @@ export { Rideable } from "./gaesup/tools/rideable";
|
|
|
17
16
|
export { ZoomButton } from "./gaesup/tools/zoomButton";
|
|
18
17
|
export { Elr, Qt, V3, V30, V31 } from "./gaesup/utils/vector";
|
|
19
18
|
export { GaesupWorld } from "./gaesup/world";
|
|
19
|
+
export { useGaesupAnimation } from "./gaesup/hooks/useGaesupAnimation";
|
|
20
|
+
export { useGaesupController } from "./gaesup/hooks/useGaesupController";
|
|
21
|
+
export * as useJoyStick from "./gaesup/hooks/useJoyStick";
|
|
22
|
+
export { usePushKey } from "./gaesup/hooks/usePushKey";
|
|
23
|
+
export { useRideable } from "./gaesup/hooks/useRideable";
|
|
24
|
+
export { useTeleport } from "./gaesup/hooks/useTeleport";
|
package/dist/index.js
CHANGED
|
@@ -6,7 +6,6 @@ export { PassiveCharacter } from "./gaesup/component/passive/character";
|
|
|
6
6
|
export { PassiveVehicle } from "./gaesup/component/passive/vehicle";
|
|
7
7
|
export { GaesupController } from "./gaesup/controller";
|
|
8
8
|
export { GaeSupProps } from "./gaesup/gaesupProps";
|
|
9
|
-
export { useGaesupController } from "./gaesup/hooks";
|
|
10
9
|
export { GameBoy } from "./gaesup/tools/gameBoy";
|
|
11
10
|
export { GamePad } from "./gaesup/tools/gamePad";
|
|
12
11
|
export { JoyStick } from "./gaesup/tools/joyStick";
|
|
@@ -17,3 +16,9 @@ export { Rideable } from "./gaesup/tools/rideable";
|
|
|
17
16
|
export { ZoomButton } from "./gaesup/tools/zoomButton";
|
|
18
17
|
export { Elr, Qt, V3, V30, V31 } from "./gaesup/utils/vector";
|
|
19
18
|
export { GaesupWorld } from "./gaesup/world";
|
|
19
|
+
export { useGaesupAnimation } from "./gaesup/hooks/useGaesupAnimation";
|
|
20
|
+
export { useGaesupController } from "./gaesup/hooks/useGaesupController";
|
|
21
|
+
export * as useJoyStick from "./gaesup/hooks/useJoyStick";
|
|
22
|
+
export { usePushKey } from "./gaesup/hooks/usePushKey";
|
|
23
|
+
export { useRideable } from "./gaesup/hooks/useRideable";
|
|
24
|
+
export { useTeleport } from "./gaesup/hooks/useTeleport";
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { useGaesupController } from "./useGaesupController";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { useGaesupController } from "./useGaesupController";
|