gaesup-world 0.6.7 → 0.6.9
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 +17 -17
- package/dist/gaesup/component/active/airplane/index.js +1 -1
- package/dist/gaesup/component/active/vehicle/index.js +1 -1
- package/dist/gaesup/component/index.js +2 -2
- package/dist/gaesup/component/inner/airplane/index.js +1 -5
- package/dist/gaesup/component/inner/common/InnerGroupRef.d.ts +11 -2
- package/dist/gaesup/component/inner/common/InnerGroupRef.js +7 -4
- package/dist/gaesup/component/inner/common/RigidbodyRef.d.ts +2 -0
- package/dist/gaesup/component/inner/common/RigidbodyRef.js +18 -18
- package/dist/gaesup/component/inner/common/type.d.ts +5 -1
- package/dist/gaesup/component/inner/rider/index.d.ts +1 -1
- package/dist/gaesup/component/inner/rider/index.js +1 -1
- package/dist/gaesup/component/inner/vehicle/index.js +1 -1
- package/dist/gaesup/component/passive/airplane/index.js +8 -11
- package/dist/gaesup/component/passive/character/index.js +8 -11
- package/dist/gaesup/component/passive/type.d.ts +1 -0
- package/dist/gaesup/component/passive/vehicle/index.js +8 -13
- package/dist/gaesup/gaesupProps/index.js +1 -1
- package/dist/gaesup/hooks/useClicker/index.d.ts +1 -1
- package/dist/gaesup/hooks/useClicker/index.js +1 -1
- package/dist/gaesup/hooks/useGaesupGltf/index.d.ts +1 -0
- package/dist/gaesup/hooks/useJoyStick/index.d.ts +2 -2
- package/dist/gaesup/hooks/useJoyStick/index.js +1 -1
- package/dist/gaesup/hooks/useRideable/index.d.ts +4 -20
- package/dist/gaesup/hooks/useRideable/index.js +1 -0
- package/dist/gaesup/hooks/useRideable/type.d.ts +19 -0
- package/dist/gaesup/physics/airplane/landing.js +26 -1
- package/dist/gaesup/physics/character/direction.d.ts +1 -1
- package/dist/gaesup/physics/check/riding.js +1 -1
- package/dist/gaesup/physics/vehicle/landing.js +26 -1
- package/dist/gaesup/tools/joystick/index.d.ts +3 -0
- package/dist/gaesup/tools/{joyStick → joystick}/index.js +1 -1
- package/dist/gaesup/tools/{joyStick → joystick}/style.css +3 -3
- package/dist/gaesup/tools/{joyStick → joystick}/type.d.ts +4 -0
- package/dist/gaesup/tools/jumpPortal/index.d.ts +0 -8
- package/dist/gaesup/tools/jumpPortal/index.js +0 -8
- package/dist/gaesup/tools/miniMap/index.js +10 -6
- package/dist/gaesup/tools/miniMap/style.css +12 -0
- package/dist/gaesup/tools/miniMap/type.d.ts +6 -1
- package/dist/gaesup/tools/rideable/index.js +1 -3
- package/dist/gaesup/tools/rideable/type.d.ts +2 -0
- package/dist/gaesup/world/context/index.js +1 -0
- package/dist/gaesup/world/context/reducer.d.ts +2 -2
- package/dist/gaesup/world/context/type.d.ts +3 -2
- package/dist/gaesup/world/initalize/index.d.ts +2 -2
- package/dist/gaesup/world/initalize/index.js +1 -1
- package/dist/index.d.ts +5 -6
- package/dist/index.js +5 -6
- package/index.ts +0 -1
- package/package.json +76 -85
- package/dist/__tests__/test/jest.test.js +0 -10
- package/dist/gaesup/tools/joyStick/index.d.ts +0 -6
- package/jest.config.cjs +0 -5
- package/vite.config.js +0 -10
- /package/dist/gaesup/{tools/gameBoy → hooks/useRideable}/type.js +0 -0
- /package/dist/gaesup/tools/{gameBoy → gameboy}/GameBoyButton.d.ts +0 -0
- /package/dist/gaesup/tools/{gameBoy → gameboy}/GameBoyButton.js +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}/style.css +0 -0
- /package/dist/gaesup/tools/{gameBoy → gameboy}/type.d.ts +0 -0
- /package/dist/gaesup/tools/{gamePad → gameboy}/type.js +0 -0
- /package/dist/gaesup/tools/{gamePad → gamepad}/GamePadButton.d.ts +0 -0
- /package/dist/gaesup/tools/{gamePad → gamepad}/GamePadButton.js +0 -0
- /package/dist/gaesup/tools/{gamePad → gamepad}/index.d.ts +0 -0
- /package/dist/gaesup/tools/{gamePad → gamepad}/index.js +0 -0
- /package/dist/gaesup/tools/{gamePad → gamepad}/style.css +0 -0
- /package/dist/gaesup/tools/{gamePad → gamepad}/type.d.ts +0 -0
- /package/dist/gaesup/tools/{joyStick → gamepad}/type.js +0 -0
- /package/dist/{__tests__/test/jest.test.d.ts → gaesup/tools/joystick/type.js} +0 -0
package/README.md
CHANGED
|
@@ -89,7 +89,7 @@ This project is distributed under the MIT License.
|
|
|
89
89
|
|
|
90
90
|
* ## 5. [Tools](#Tools)
|
|
91
91
|
|
|
92
|
-
- [
|
|
92
|
+
- [joystick](#1joystick)
|
|
93
93
|
|
|
94
94
|
* [keyBoardTooltip](#keyBoardTooltip)
|
|
95
95
|
|
|
@@ -123,7 +123,7 @@ This is the character control in Gaesup World.
|
|
|
123
123
|
| Name | Condition | Info |
|
|
124
124
|
| -------- | --------------------------- | ----------------------------------------------------------------------- |
|
|
125
125
|
| Keyboard | desktop | A standard keyboard tool. You can see where on the keyboard is clicked. |
|
|
126
|
-
|
|
|
126
|
+
| joystick | mobile (not normal control) | A joystick implementation tool. It works on mobile devices. |
|
|
127
127
|
| Gameboy | mobile | A Gameboy implementation tool. It works on mobile devices. |
|
|
128
128
|
|
|
129
129
|
## Vehicle
|
|
@@ -141,7 +141,7 @@ This is the character control in Gaesup World.
|
|
|
141
141
|
| Name | Condition | Info |
|
|
142
142
|
| -------- | --------- | ----------------------------------------------------------------------- |
|
|
143
143
|
| Keyboard | desktop | A standard keyboard tool. You can see where on the keyboard is clicked. |
|
|
144
|
-
|
|
|
144
|
+
| joystick | mobile | A joystick implementation tool. It works on mobile devices. |
|
|
145
145
|
| Gameboy | mobile | A Gameboy implementation tool. It works on mobile devices. |
|
|
146
146
|
|
|
147
147
|
## Airplane
|
|
@@ -159,7 +159,7 @@ the airplane control in Gaesup World. Characters can board the airplane.
|
|
|
159
159
|
| Name | Condition | Info |
|
|
160
160
|
| -------- | --------- | ----------------------------------------------------------------------- |
|
|
161
161
|
| Keyboard | desktop | A standard keyboard tool. You can see where on the keyboard is clicked. |
|
|
162
|
-
|
|
|
162
|
+
| joystick | mobile | A joystick implementation tool. It works on mobile devices. |
|
|
163
163
|
| Gameboy | mobile | A Gameboy implementation tool. It works on mobile devices. |
|
|
164
164
|
|
|
165
165
|
# Animation
|
|
@@ -410,36 +410,36 @@ const App = () => {
|
|
|
410
410
|
2. Customize the appearance using the `gamePadStyle` and `gamePadButtonStyle` properties.
|
|
411
411
|
3. The component dynamically renders buttons based on the `control` mode.
|
|
412
412
|
|
|
413
|
-
##
|
|
413
|
+
## joystick
|
|
414
414
|
|
|
415
415
|
---
|
|
416
416
|
|
|
417
|
-
- The
|
|
417
|
+
- 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.
|
|
418
418
|
|
|
419
419
|
### (1) props
|
|
420
420
|
|
|
421
421
|
| Prop Name | Type | Required | Description | Default Value |
|
|
422
422
|
| ------------------- | --------------- | -------- | --------------------------- | ------------- |
|
|
423
|
-
| `
|
|
424
|
-
| `
|
|
423
|
+
| `joystickStyle` | object (styles) | Optional | Style for the joystick | `undefined` |
|
|
424
|
+
| `joystickBallStyle` | object (styles) | Optional | Style for the joystick ball | `undefined` |
|
|
425
425
|
|
|
426
426
|
### (2) example
|
|
427
427
|
|
|
428
428
|
```jsx
|
|
429
429
|
const MyComponent = () => {
|
|
430
|
-
const
|
|
431
|
-
/*
|
|
430
|
+
const joystickStyle = {
|
|
431
|
+
/* joystickStyle */
|
|
432
432
|
};
|
|
433
|
-
const
|
|
434
|
-
/*
|
|
433
|
+
const joystickBallStyle = {
|
|
434
|
+
/* joystickBallStyle */
|
|
435
435
|
};
|
|
436
436
|
|
|
437
437
|
return (
|
|
438
438
|
<GaesupWorld>
|
|
439
439
|
{/* ... */}
|
|
440
|
-
<
|
|
441
|
-
|
|
442
|
-
|
|
440
|
+
<joystick
|
|
441
|
+
joystickStyle={joystickStyle}
|
|
442
|
+
joystickBallStyle={joystickBallStyle}
|
|
443
443
|
/>
|
|
444
444
|
{/* ... */}
|
|
445
445
|
</GaesupWorld>
|
|
@@ -449,8 +449,8 @@ const MyComponent = () => {
|
|
|
449
449
|
|
|
450
450
|
### (3) Key Features:
|
|
451
451
|
|
|
452
|
-
- **
|
|
453
|
-
- **Customization:** You can customize the style of the
|
|
452
|
+
- **joystick Interface:** Provides a joystick-like user input interface, suitable for mobile devices.
|
|
453
|
+
- **Customization:** You can customize the style of the joystick component by adjusting the styles of the joystick and the joystick ball using the `joystickBallStyle` and `joystickStyle` properties.
|
|
454
454
|
- **Responsive and Interactive:** It supports various input devices and responds to both mouse and mobile touch events for controlling movement.
|
|
455
455
|
|
|
456
456
|
## 4) JumpPortal
|
|
@@ -12,5 +12,5 @@ var __assign = (this && this.__assign) || function () {
|
|
|
12
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
13
|
import { AirplaneInnerRef } from "../../inner/airplane";
|
|
14
14
|
export function AirplaneRef(props) {
|
|
15
|
-
return (_jsx(AirplaneInnerRef, __assign({ name: "airplane", isActive: true, currentAnimation: "idle", componentType: "airplane" }, props, { children: props.children })));
|
|
15
|
+
return (_jsx(AirplaneInnerRef, __assign({ name: "airplane", isActive: true, currentAnimation: "idle", componentType: "airplane", ridingUrl: props.ridingUrl }, props, { children: props.children })));
|
|
16
16
|
}
|
|
@@ -12,5 +12,5 @@ var __assign = (this && this.__assign) || function () {
|
|
|
12
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
13
|
import { VehicleInnerRef } from "../../inner/vehicle";
|
|
14
14
|
export function VehicleRef(props) {
|
|
15
|
-
return (_jsx(VehicleInnerRef, __assign({ name: "vehicle", isActive: true, currentAnimation: "idle", componentType: "vehicle" }, props, { children: props.children })));
|
|
15
|
+
return (_jsx(VehicleInnerRef, __assign({ name: "vehicle", isActive: true, currentAnimation: "idle", componentType: "vehicle", ridingUrl: props.ridingUrl }, props, { children: props.children })));
|
|
16
16
|
}
|
|
@@ -20,9 +20,9 @@ export function GaesupComponent(_a) {
|
|
|
20
20
|
var props = _a.props, refs = _a.refs, urls = _a.urls;
|
|
21
21
|
var _b = useContext(GaesupWorldContext), mode = _b.mode, states = _b.states, rideable = _b.rideable;
|
|
22
22
|
var enableRiding = states.enableRiding, isRiderOn = states.isRiderOn, rideableId = states.rideableId;
|
|
23
|
-
return (_jsxs(_Fragment, { children: [mode.type === "character" && (_jsx(CharacterRef, { props: props, refs: refs, urls: urls })), mode.type === "vehicle" && (_jsx(VehicleRef, __assign({ controllerOptions: props.controllerOptions, url: urls.vehicleUrl, wheelUrl: urls.wheelUrl, enableRiding: enableRiding, isRiderOn: isRiderOn, offset: rideableId && rideable[rideableId]
|
|
23
|
+
return (_jsxs(_Fragment, { children: [mode.type === "character" && (_jsx(CharacterRef, { props: props, refs: refs, urls: urls })), mode.type === "vehicle" && (_jsx(VehicleRef, __assign({ controllerOptions: props.controllerOptions, url: urls.vehicleUrl, wheelUrl: urls.wheelUrl, ridingUrl: urls.ridingUrl, enableRiding: enableRiding, isRiderOn: isRiderOn, offset: rideableId && rideable[rideableId]
|
|
24
24
|
? rideable[rideableId].offset
|
|
25
|
-
: vec3() }, refs, { children: props.children }))), mode.type === "airplane" && (_jsx(AirplaneRef, __assign({ controllerOptions: props.controllerOptions, url: urls.airplaneUrl, enableRiding: enableRiding, isRiderOn: isRiderOn, offset: rideableId && rideable[rideableId]
|
|
25
|
+
: vec3() }, refs, { children: props.children }))), mode.type === "airplane" && (_jsx(AirplaneRef, __assign({ controllerOptions: props.controllerOptions, url: urls.airplaneUrl, ridingUrl: urls.ridingUrl, enableRiding: enableRiding, isRiderOn: isRiderOn, offset: rideableId && rideable[rideableId]
|
|
26
26
|
? rideable[rideableId].offset
|
|
27
27
|
: vec3() }, refs, { children: props.children })))] }));
|
|
28
28
|
}
|
|
@@ -10,13 +10,9 @@ var __assign = (this && this.__assign) || function () {
|
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
11
|
};
|
|
12
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
-
import { useGltfAndSize } from "../../../hooks/useGaesupGltf";
|
|
14
13
|
import { OuterGroupRef } from "../common/OuterGroupRef";
|
|
15
14
|
import { RigidBodyRef } from "../common/RigidbodyRef";
|
|
16
15
|
export function AirplaneInnerRef(props) {
|
|
17
16
|
var rigidBodyRef = props.rigidBodyRef, outerGroupRef = props.outerGroupRef;
|
|
18
|
-
|
|
19
|
-
url: props.url,
|
|
20
|
-
}).size;
|
|
21
|
-
return (_jsx(OuterGroupRef, { ref: outerGroupRef, children: _jsx(RigidBodyRef, __assign({ ref: rigidBodyRef, name: props.name, componentType: "airplane" }, props, { children: props.children })) }));
|
|
17
|
+
return (_jsx(OuterGroupRef, { ref: outerGroupRef, children: _jsx(RigidBodyRef, __assign({ ref: rigidBodyRef, name: props.name, componentType: "airplane", ridingUrl: props.ridingUrl }, props, { children: props.children })) }));
|
|
22
18
|
}
|
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import * as THREE from "three";
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
export declare const InnerGroupRef: import("react").ForwardRefExoticComponent<{
|
|
4
|
+
children?: import("react").ReactNode;
|
|
5
|
+
objectNode: THREE.Object3D<THREE.Object3DEventMap>;
|
|
6
|
+
animationRef: import("react").MutableRefObject<THREE.Object3D<THREE.Object3DEventMap>>;
|
|
7
|
+
nodes: {
|
|
8
|
+
[name: string]: THREE.Object3D<THREE.Object3DEventMap>;
|
|
9
|
+
};
|
|
10
|
+
isActive?: boolean;
|
|
11
|
+
ridingUrl?: string;
|
|
12
|
+
offset?: THREE.Vector3;
|
|
13
|
+
} & import("./type").ridingType & import("react").RefAttributes<THREE.Group<THREE.Object3DEventMap>>>;
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef } from "react";
|
|
3
3
|
import * as THREE from "three";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
return (_jsxs("group", { receiveShadow: true, castShadow: true, ref: ref, userData: { intangible: true }, children: [
|
|
7
|
-
|
|
4
|
+
import RiderRef from "../rider";
|
|
5
|
+
export var InnerGroupRef = forwardRef(function (props, ref) {
|
|
6
|
+
return (_jsxs("group", { receiveShadow: true, castShadow: true, ref: ref, userData: { intangible: true }, children: [props.isRiderOn &&
|
|
7
|
+
props.enableRiding &&
|
|
8
|
+
props.isActive &&
|
|
9
|
+
props.ridingUrl && (_jsx(RiderRef, { url: props.ridingUrl, offset: props.offset })), props.children, props.objectNode && props.animationRef && (_jsx("primitive", { object: props.objectNode, visible: false, receiveShadow: true, castShadow: true, ref: props.animationRef })), Object.keys(props.nodes).map(function (name, key) {
|
|
10
|
+
var node = props.nodes[name];
|
|
8
11
|
if (node instanceof THREE.SkinnedMesh) {
|
|
9
12
|
return (_jsx("skinnedMesh", { castShadow: true, receiveShadow: true, material: node.material, geometry: node.geometry, skeleton: node.skeleton }, key));
|
|
10
13
|
}
|
|
@@ -8,9 +8,11 @@ export declare const RigidBodyRef: import("react").ForwardRefExoticComponent<{
|
|
|
8
8
|
};
|
|
9
9
|
onCollisionEnter?: (e: import("@react-three/rapier").CollisionEnterPayload) => Promise<void>;
|
|
10
10
|
isActive?: boolean;
|
|
11
|
+
ridingUrl?: string;
|
|
11
12
|
} & {
|
|
12
13
|
children?: import("react").ReactNode;
|
|
13
14
|
url: string;
|
|
15
|
+
ridingUrl?: string;
|
|
14
16
|
wheelUrl?: string;
|
|
15
17
|
position?: THREE.Vector3;
|
|
16
18
|
rotation?: THREE.Euler;
|
|
@@ -14,9 +14,9 @@ import { V3 } from "../../../utils";
|
|
|
14
14
|
import { GaesupWorldContext } from "../../../world/context";
|
|
15
15
|
import { calcCharacterColliderProps } from "../../inner/common/calc";
|
|
16
16
|
import { InnerGroupRef } from "./InnerGroupRef";
|
|
17
|
-
export var RigidBodyRef = forwardRef(function (
|
|
18
|
-
var
|
|
19
|
-
var size = useGltfAndSize({ url: url }).size;
|
|
17
|
+
export var RigidBodyRef = forwardRef(function (props, ref) {
|
|
18
|
+
var _a;
|
|
19
|
+
var size = useGltfAndSize({ url: props.url }).size;
|
|
20
20
|
var collider = calcCharacterColliderProps(size);
|
|
21
21
|
var groundRay = useMemo(function () {
|
|
22
22
|
return {
|
|
@@ -42,13 +42,13 @@ export var RigidBodyRef = forwardRef(function (_a, ref) {
|
|
|
42
42
|
groundRay.hit = world.castRay(groundRay.rayCast, groundRay.length, true, undefined, undefined);
|
|
43
43
|
groundRay.parent = (_a = groundRay.hit) === null || _a === void 0 ? void 0 : _a.collider.parent();
|
|
44
44
|
});
|
|
45
|
-
var _c = useGLTF(url), scene = _c.scene, animations = _c.animations;
|
|
45
|
+
var _c = useGLTF(props.url), scene = _c.scene, animations = _c.animations;
|
|
46
46
|
var _d = useAnimations(animations), actions = _d.actions, animationRef = _d.ref;
|
|
47
47
|
var worldContext = useContext(GaesupWorldContext);
|
|
48
48
|
var controllerContext = useContext(GaesupControllerContext);
|
|
49
|
-
if (isActive) {
|
|
49
|
+
if (props.isActive) {
|
|
50
50
|
subscribeActions({
|
|
51
|
-
type: componentType,
|
|
51
|
+
type: props.componentType,
|
|
52
52
|
groundRay: groundRay,
|
|
53
53
|
animations: animations,
|
|
54
54
|
});
|
|
@@ -56,36 +56,36 @@ export var RigidBodyRef = forwardRef(function (_a, ref) {
|
|
|
56
56
|
state: null,
|
|
57
57
|
worldContext: worldContext,
|
|
58
58
|
controllerContext: controllerContext,
|
|
59
|
-
controllerOptions: controllerOptions,
|
|
59
|
+
controllerOptions: props.controllerOptions,
|
|
60
60
|
};
|
|
61
61
|
useFrame(function (state) {
|
|
62
62
|
cameraProps_1.state = state;
|
|
63
63
|
});
|
|
64
64
|
Camera(cameraProps_1);
|
|
65
65
|
calculation({
|
|
66
|
-
outerGroupRef: outerGroupRef,
|
|
67
|
-
innerGroupRef: innerGroupRef,
|
|
66
|
+
outerGroupRef: props.outerGroupRef,
|
|
67
|
+
innerGroupRef: props.innerGroupRef,
|
|
68
68
|
rigidBodyRef: ref,
|
|
69
|
-
colliderRef: colliderRef,
|
|
69
|
+
colliderRef: props.colliderRef,
|
|
70
70
|
groundRay: groundRay,
|
|
71
71
|
});
|
|
72
72
|
}
|
|
73
73
|
playActions({
|
|
74
|
-
type: componentType,
|
|
74
|
+
type: props.componentType,
|
|
75
75
|
actions: actions,
|
|
76
76
|
animationRef: animationRef,
|
|
77
|
-
currentAnimation: isActive ? undefined : currentAnimation,
|
|
78
|
-
isActive: isActive,
|
|
77
|
+
currentAnimation: props.isActive ? undefined : props.currentAnimation,
|
|
78
|
+
isActive: props.isActive,
|
|
79
79
|
});
|
|
80
80
|
var clone = useMemo(function () { return SkeletonUtils.clone(scene); }, [scene]);
|
|
81
81
|
var nodes = useGraph(clone).nodes;
|
|
82
82
|
var objectNode = Object.values(nodes).find(function (node) { return node.type === "Object3D"; });
|
|
83
83
|
useFrame(function () {
|
|
84
|
-
if (isActive || !position || !ref || !ref.current)
|
|
84
|
+
if (props.isActive || !props.position || !ref || !ref.current)
|
|
85
85
|
return;
|
|
86
|
-
ref.current.setTranslation(V3(THREE.MathUtils.lerp(ref.current.translation().x, position.x, controllerOptions.lerp.cameraPosition), THREE.MathUtils.lerp(ref.current.translation().y, position.y, controllerOptions.lerp.cameraPosition), THREE.MathUtils.lerp(ref.current.translation().z, position.z, controllerOptions.lerp.cameraPosition)), false);
|
|
86
|
+
ref.current.setTranslation(V3(THREE.MathUtils.lerp(ref.current.translation().x, props.position.x, props.controllerOptions.lerp.cameraPosition), THREE.MathUtils.lerp(ref.current.translation().y, props.position.y, props.controllerOptions.lerp.cameraPosition), THREE.MathUtils.lerp(ref.current.translation().z, props.position.z, props.controllerOptions.lerp.cameraPosition)), false);
|
|
87
87
|
});
|
|
88
|
-
return (_jsxs(RigidBody, { colliders: false, ref: ref, name: name, rotation: euler()
|
|
89
|
-
.set(0, (rotation === null ||
|
|
90
|
-
.clone(), userData: userData, onCollisionEnter: onCollisionEnter, type: rigidbodyType || (isActive ? "dynamic" : "fixed"), children: [_jsx(CapsuleCollider, { ref: colliderRef, args: [(size.y / 2 - size.x) * 1.2, size.x * 1.2], position: [0, (size.y / 2 + size.x / 2) * 1.2, 0] }), children, _jsx(InnerGroupRef, { objectNode: objectNode, animationRef: animationRef, nodes: nodes, ref: innerGroupRef, children: children })] }));
|
|
88
|
+
return (_jsxs(RigidBody, { colliders: false, ref: ref, name: props.name, rotation: euler()
|
|
89
|
+
.set(0, ((_a = props.rotation) === null || _a === void 0 ? void 0 : _a.clone().y) || 0, 0)
|
|
90
|
+
.clone(), userData: props.userData, onCollisionEnter: props.onCollisionEnter, type: props.rigidbodyType || (props.isActive ? "dynamic" : "fixed"), children: [_jsx(CapsuleCollider, { ref: props.colliderRef, args: [(size.y / 2 - size.x) * 1.2, size.x * 1.2], position: [0, (size.y / 2 + size.x / 2) * 1.2, 0] }), props.children, _jsx(InnerGroupRef, { objectNode: objectNode, animationRef: animationRef, nodes: nodes, ref: props.innerGroupRef, isActive: props.isActive, isRiderOn: props.isRiderOn, enableRiding: props.enableRiding, ridingUrl: props.ridingUrl, offset: props.offset, children: props.children })] }));
|
|
91
91
|
});
|
|
@@ -18,7 +18,10 @@ export type InnerGroupRefType = {
|
|
|
18
18
|
nodes: {
|
|
19
19
|
[name: string]: THREE.Object3D<THREE.Object3DEventMap>;
|
|
20
20
|
};
|
|
21
|
-
|
|
21
|
+
isActive?: boolean;
|
|
22
|
+
ridingUrl?: string;
|
|
23
|
+
offset?: THREE.Vector3;
|
|
24
|
+
} & ridingType;
|
|
22
25
|
export type ridingType = {
|
|
23
26
|
isRiderOn?: boolean;
|
|
24
27
|
enableRiding?: boolean;
|
|
@@ -51,4 +54,5 @@ export type rigidBodyRefType = {
|
|
|
51
54
|
};
|
|
52
55
|
onCollisionEnter?: (e: CollisionEnterPayload) => Promise<void>;
|
|
53
56
|
isActive?: boolean;
|
|
57
|
+
ridingUrl?: string;
|
|
54
58
|
} & passivePropsType & innerRefType;
|
|
@@ -7,4 +7,4 @@ export type riderRefType = {
|
|
|
7
7
|
euler?: THREE.Euler;
|
|
8
8
|
currentAnimation?: string;
|
|
9
9
|
};
|
|
10
|
-
export default function RiderRef({ url, children, offset,
|
|
10
|
+
export default function RiderRef({ url, children, offset, currentAnimation, }: riderRefType): import("react/jsx-runtime").JSX.Element;
|
|
@@ -7,7 +7,7 @@ import { SkeletonUtils } from "three-stdlib";
|
|
|
7
7
|
import playActions from "../../../animation/actions";
|
|
8
8
|
import { useGltfAndSize } from "../../../hooks/useGaesupGltf";
|
|
9
9
|
export default function RiderRef(_a) {
|
|
10
|
-
var url = _a.url, children = _a.children, offset = _a.offset,
|
|
10
|
+
var url = _a.url, children = _a.children, offset = _a.offset, currentAnimation = _a.currentAnimation;
|
|
11
11
|
var gltf = useGltfAndSize({ url: url }).gltf;
|
|
12
12
|
var animations = gltf.animations, scene = gltf.scene;
|
|
13
13
|
var _b = useAnimations(animations), actions = _b.actions, animationRef = _b.ref;
|
|
@@ -18,5 +18,5 @@ export function VehicleInnerRef(props) {
|
|
|
18
18
|
var size = useGltfAndSize({
|
|
19
19
|
url: props.url,
|
|
20
20
|
}).size;
|
|
21
|
-
return (_jsx(OuterGroupRef, { ref: outerGroupRef, children: _jsx(RigidBodyRef, __assign({ ref: rigidBodyRef, name: props.name, componentType: "vehicle" }, props, { children: props.children })) }));
|
|
21
|
+
return (_jsx(OuterGroupRef, { ref: outerGroupRef, children: _jsx(RigidBodyRef, __assign({ ref: rigidBodyRef, name: props.name, componentType: "vehicle", ridingUrl: props.ridingUrl }, props, { children: props.children })) }));
|
|
22
22
|
}
|
|
@@ -9,10 +9,10 @@ var __assign = (this && this.__assign) || function () {
|
|
|
9
9
|
};
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
11
|
};
|
|
12
|
-
import { jsx as _jsx
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
13
|
import { useFrame } from "@react-three/fiber";
|
|
14
14
|
import { quat } from "@react-three/rapier";
|
|
15
|
-
import {
|
|
15
|
+
import { useRef } from "react";
|
|
16
16
|
import { AirplaneInnerRef } from "../../inner/airplane";
|
|
17
17
|
export function PassiveAirplane(props) {
|
|
18
18
|
var rigidBodyRef = useRef(null);
|
|
@@ -39,13 +39,10 @@ export function PassiveAirplane(props) {
|
|
|
39
39
|
: 0.1, false);
|
|
40
40
|
}
|
|
41
41
|
});
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}, position: props.position.clone(), rotation: props.rotation.clone(), currentAnimation: props.currentAnimation }, props, refs, { children: props.children })));
|
|
49
|
-
}, [props.position, props.rotation, props.currentAnimation]);
|
|
50
|
-
return _jsx(_Fragment, { children: memorized });
|
|
42
|
+
return (_jsx(AirplaneInnerRef, __assign({ isActive: false, componentType: "airplane", name: "airplane", controllerOptions: props.controllerOptions || {
|
|
43
|
+
lerp: {
|
|
44
|
+
cameraTurn: 1,
|
|
45
|
+
cameraPosition: 1,
|
|
46
|
+
},
|
|
47
|
+
}, position: props.position, rotation: props.rotation, currentAnimation: props.currentAnimation, ridingUrl: props.ridingUrl }, props, refs, { children: props.children })));
|
|
51
48
|
}
|
|
@@ -9,8 +9,8 @@ var __assign = (this && this.__assign) || function () {
|
|
|
9
9
|
};
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
11
|
};
|
|
12
|
-
import { jsx as _jsx
|
|
13
|
-
import { useEffect,
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
import { useEffect, useRef } from "react";
|
|
14
14
|
import { CharacterInnerRef } from "../../inner/character";
|
|
15
15
|
export function PassiveCharacter(props) {
|
|
16
16
|
var rigidBodyRef = useRef(null);
|
|
@@ -28,13 +28,10 @@ export function PassiveCharacter(props) {
|
|
|
28
28
|
rigidBodyRef.current.setEnabledRotations(false, false, false, false);
|
|
29
29
|
}
|
|
30
30
|
}, []);
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}, position: props.position.clone(), rotation: props.rotation.clone(), currentAnimation: props.currentAnimation }, refs, props, { children: props.children })));
|
|
38
|
-
}, [props.position, props.rotation, props.currentAnimation]);
|
|
39
|
-
return _jsx(_Fragment, { children: memorized });
|
|
31
|
+
return (_jsx(CharacterInnerRef, __assign({ isActive: false, componentType: "character", controllerOptions: props.controllerOptions || {
|
|
32
|
+
lerp: {
|
|
33
|
+
cameraTurn: 1,
|
|
34
|
+
cameraPosition: 1,
|
|
35
|
+
},
|
|
36
|
+
}, position: props.position, rotation: props.rotation, currentAnimation: props.currentAnimation }, refs, props, { children: props.children })));
|
|
40
37
|
}
|
|
@@ -9,12 +9,10 @@ var __assign = (this && this.__assign) || function () {
|
|
|
9
9
|
};
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
11
|
};
|
|
12
|
-
import { jsx as _jsx
|
|
13
|
-
import {
|
|
14
|
-
import { GaesupWorldContext } from "../../../world/context";
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
import { useRef } from "react";
|
|
15
14
|
import { VehicleInnerRef } from "../../inner/vehicle";
|
|
16
15
|
export function PassiveVehicle(props) {
|
|
17
|
-
var states = useContext(GaesupWorldContext).states;
|
|
18
16
|
var rigidBodyRef = useRef(null);
|
|
19
17
|
var outerGroupRef = useRef(null);
|
|
20
18
|
var innerGroupRef = useRef(null);
|
|
@@ -25,13 +23,10 @@ export function PassiveVehicle(props) {
|
|
|
25
23
|
innerGroupRef: innerGroupRef,
|
|
26
24
|
colliderRef: colliderRef,
|
|
27
25
|
};
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}, position: props.position.clone(), rotation: props.rotation.clone(), currentAnimation: props.currentAnimation }, props, refs, { children: props.children })));
|
|
35
|
-
}, [props.position, props.rotation, props.currentAnimation]);
|
|
36
|
-
return _jsx(_Fragment, { children: memorized });
|
|
26
|
+
return (_jsx(VehicleInnerRef, __assign({ isActive: false, componentType: "vehicle", name: "vehicle", controllerOptions: props.controllerOptions || {
|
|
27
|
+
lerp: {
|
|
28
|
+
cameraTurn: 1,
|
|
29
|
+
cameraPosition: 1,
|
|
30
|
+
},
|
|
31
|
+
}, position: props.position, rotation: props.rotation, currentAnimation: props.currentAnimation, ridingUrl: props.ridingUrl }, props, refs, { children: props.children })));
|
|
37
32
|
}
|
|
@@ -13,7 +13,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
13
13
|
import { vec3 } from "@react-three/rapier";
|
|
14
14
|
import { useContext, useEffect, useRef } from "react";
|
|
15
15
|
import * as THREE from "three";
|
|
16
|
-
import useClicker from "../hooks/useClicker";
|
|
16
|
+
import { useClicker } from "../hooks/useClicker";
|
|
17
17
|
import { GaesupWorldContext, GaesupWorldDispatchContext, } from "../world/context";
|
|
18
18
|
export function GaeSupProps(_a) {
|
|
19
19
|
var _b = _a.type, type = _b === void 0 ? "normal" : _b, text = _a.text, position = _a.position, children = _a.children;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useContext, useEffect } from "react";
|
|
2
2
|
import { V3 } from "../../utils";
|
|
3
3
|
import { GaesupWorldContext, GaesupWorldDispatchContext, } from "../../world/context";
|
|
4
|
-
export
|
|
4
|
+
export function useClicker() {
|
|
5
5
|
var _a = useContext(GaesupWorldContext), activeState = _a.activeState, clicker = _a.clicker, mode = _a.mode;
|
|
6
6
|
var dispatch = useContext(GaesupWorldDispatchContext);
|
|
7
7
|
var moveClicker = function (e, isRun, type) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { joyStickBallType, joyStickOriginType } from "../../tools/
|
|
1
|
+
import { joyStickBallType, joyStickOriginType } from "../../tools/joystick/type";
|
|
2
2
|
export declare const joyStickBallDefault: {
|
|
3
3
|
top: string;
|
|
4
4
|
left: string;
|
|
@@ -31,7 +31,7 @@ export declare const joyStickInnerDefault: {
|
|
|
31
31
|
isCenter: boolean;
|
|
32
32
|
};
|
|
33
33
|
};
|
|
34
|
-
export
|
|
34
|
+
export declare function useJoyStick(): {
|
|
35
35
|
joyStickOrigin: joyStickOriginType;
|
|
36
36
|
joyStickBall: joyStickBallType;
|
|
37
37
|
setBall: (ball: joyStickBallType) => void;
|
|
@@ -30,7 +30,7 @@ export var joyStickInnerDefault = {
|
|
|
30
30
|
joyStickBall: joyStickBallDefault,
|
|
31
31
|
joyStickOrigin: joyStickOriginDefault,
|
|
32
32
|
};
|
|
33
|
-
export
|
|
33
|
+
export function useJoyStick() {
|
|
34
34
|
var joystick = useContext(GaesupWorldContext).joystick;
|
|
35
35
|
var dispatch = useContext(GaesupWorldDispatchContext);
|
|
36
36
|
var joyStickBall = joystick.joyStickBall, joyStickOrigin = joystick.joyStickOrigin;
|
|
@@ -1,32 +1,16 @@
|
|
|
1
1
|
import { CollisionEnterPayload } from "@react-three/rapier";
|
|
2
|
-
import
|
|
2
|
+
import { rideableType } from "./type";
|
|
3
3
|
export declare const rideableDefault: {
|
|
4
4
|
objectkey: any;
|
|
5
5
|
objectType: any;
|
|
6
6
|
isRiderOn: boolean;
|
|
7
7
|
url: any;
|
|
8
8
|
wheelUrl: any;
|
|
9
|
-
position:
|
|
10
|
-
rotation:
|
|
11
|
-
offset:
|
|
9
|
+
position: import("three").Vector3;
|
|
10
|
+
rotation: import("three").Euler;
|
|
11
|
+
offset: import("three").Vector3;
|
|
12
12
|
visible: boolean;
|
|
13
13
|
};
|
|
14
|
-
export type rideableType = {
|
|
15
|
-
objectkey: string;
|
|
16
|
-
objectType?: "vehicle" | "airplane";
|
|
17
|
-
enableRiding?: boolean;
|
|
18
|
-
isRiderOn?: boolean;
|
|
19
|
-
url?: string;
|
|
20
|
-
wheelUrl?: string;
|
|
21
|
-
position?: THREE.Vector3;
|
|
22
|
-
rotation?: THREE.Euler;
|
|
23
|
-
offset?: THREE.Vector3;
|
|
24
|
-
landingOffset?: THREE.Vector3;
|
|
25
|
-
visible?: boolean;
|
|
26
|
-
vehicleSize?: THREE.Vector3;
|
|
27
|
-
wheelSize?: THREE.Vector3;
|
|
28
|
-
airplaneSize?: THREE.Vector3;
|
|
29
|
-
};
|
|
30
14
|
export declare function useRideable(): {
|
|
31
15
|
initRideable: (props: rideableType) => void;
|
|
32
16
|
setRideable: (props: rideableType) => void;
|
|
@@ -102,6 +102,7 @@ export function useRideable() {
|
|
|
102
102
|
};
|
|
103
103
|
var setUrl = function (props) { return __awaiter(_this, void 0, void 0, function () {
|
|
104
104
|
return __generator(this, function (_a) {
|
|
105
|
+
urls.ridingUrl = props.ridingUrl || urls.characterUrl || null;
|
|
105
106
|
if (props.objectType === "vehicle") {
|
|
106
107
|
urls.vehicleUrl = props.url;
|
|
107
108
|
urls.wheelUrl = props.wheelUrl || null;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as THREE from "three";
|
|
2
|
+
export type rideableType = {
|
|
3
|
+
objectkey: string;
|
|
4
|
+
objectType?: "vehicle" | "airplane";
|
|
5
|
+
enableRiding?: boolean;
|
|
6
|
+
isRiderOn?: boolean;
|
|
7
|
+
url?: string;
|
|
8
|
+
characterUrl?: string;
|
|
9
|
+
ridingUrl?: string;
|
|
10
|
+
wheelUrl?: string;
|
|
11
|
+
position?: THREE.Vector3;
|
|
12
|
+
rotation?: THREE.Euler;
|
|
13
|
+
offset?: THREE.Vector3;
|
|
14
|
+
landingOffset?: THREE.Vector3;
|
|
15
|
+
visible?: boolean;
|
|
16
|
+
vehicleSize?: THREE.Vector3;
|
|
17
|
+
wheelSize?: THREE.Vector3;
|
|
18
|
+
airplaneSize?: THREE.Vector3;
|
|
19
|
+
};
|
|
@@ -1,4 +1,29 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
1
12
|
export default function landing(prop) {
|
|
2
13
|
var _a = prop.worldContext, states = _a.states, rideable = _a.rideable, mode = _a.mode, dispatch = prop.dispatch;
|
|
3
|
-
var
|
|
14
|
+
var isRiding = states.isRiding;
|
|
15
|
+
if (isRiding) {
|
|
16
|
+
rideable.objectType = null;
|
|
17
|
+
rideable.key = null;
|
|
18
|
+
mode.type = "character";
|
|
19
|
+
states.isRiding = false;
|
|
20
|
+
states.enableRiding = false;
|
|
21
|
+
}
|
|
22
|
+
dispatch({
|
|
23
|
+
type: "update",
|
|
24
|
+
payload: {
|
|
25
|
+
mode: __assign({}, mode),
|
|
26
|
+
rideable: __assign({}, rideable),
|
|
27
|
+
},
|
|
28
|
+
});
|
|
4
29
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { joyStickInnerType } from "../../tools/
|
|
1
|
+
import { joyStickInnerType } from "../../tools/joystick/type";
|
|
2
2
|
import { activeStateType, clickerType, modeType } from "../../world/context/type";
|
|
3
3
|
import { calcType } from "../type";
|
|
4
4
|
export declare function orbitDirection({ activeState, control, mode, joystick, clicker, }: {
|