0.8.47 • Published 4 days ago

gaesup-world v0.8.47

Weekly downloads
-
License
MIT
Repository
github
Last release
4 days ago

Gaesup World

Version Downloads

Web 3D Character Controller and World Platform Library

ezgif-7-177168be04

introduction

  • Gaesup World is a library that uses @react/three-fiber,@react/three-drei, and react-three-rapier to provide control tools for characters, airplanes, cars, and more in a web 3D environment.

  • This controller is designed to easily manage character movement, animation, and interaction. It allows for easy manipulation of characters or vehicles in a virtual world, and is also equipped with utilities like minimaps and joysticks.

How to start

import ...

export default function App() {
  const CHARACTER_URL = S3 + "/gaesupyee.glb";
  return (
    <GaesupWorld
      url={{
        characterUrl: CHARACTER_URL,
      }}
      mode={{
        ...
      }}
    >
      <Canvas>
        <Physics>
          <GaesupController />
        </Physics>
      </Canvas>
    </GaesupWorld>
  );
}

Features

  • 3D character control based on React Three Fiber.
  • Simple API for controlling character movement and animation.
  • Extensible structure for various customizations.
  • Lightweight library for fast loading and performance optimization.

Installation

npm install @react-three/fiber @react-three/drei three @types/three @react-three/rapier ../../../src

Or

yarn add @react-three/fiber @react-three/drei three @types/three @react-three/rapier ../../../src

4) How to Contribute

If you would like to contribute to this project, please follow these steps:

  1. Fork the project.
  2. go to dev branch ( git checkout dev ).
  3. Commit your changes (git commit -m 'Add some AmazingFeature').
  4. Push to the branch (git push origin dev).
  5. Create a Pull Request.

5) License

This project is distributed under the MIT License.

PlayerType


Character

This is the character control in Gaesup World.

  • Possible Camera Types
NameInfo
NormalPositioned parallel to the Z-axis from the character's location and not affected by rotation.
OrbitMoves with the character and rotates according to the character's direction.
  • Controller Tools
NameConditionInfo
KeyboarddesktopA standard keyboard tool. You can see where on the keyboard is clicked.
joystickmobile (not normal control)A joystick implementation tool. It works on mobile devices.
GameboymobileA Gameboy implementation tool. It works on mobile devices.

Vehicle

  • This is the vehicle control in Gaesup World. Characters can board the vehicle.
  • Possible Camera Types (only orbit type available)
NameControlInfo
OrbitOrbit ControlMoves with the character and rotates according to the character's direction.
  • Controller Tools
NameConditionInfo
KeyboarddesktopA standard keyboard tool. You can see where on the keyboard is clicked.
joystickmobileA joystick implementation tool. It works on mobile devices.
GameboymobileA Gameboy implementation tool. It works on mobile devices.

Airplane

the airplane control in Gaesup World. Characters can board the airplane.

  • Possible Camera Types (only orbit type available)
NameControlInfo
OrbitOrbit ControlMoves with the character and rotates according to the character's direction.
  • Controller Tools
NameConditionInfo
KeyboarddesktopA standard keyboard tool. You can see where on the keyboard is clicked.
joystickmobileA joystick implementation tool. It works on mobile devices.
GameboymobileA Gameboy implementation tool. It works on mobile devices.

Animation

  • Animation refers to the method of controlling animations for characters and other elements in the Gaesup World.

Rideable

  • 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.

example)

(1) Example

export default function App() {
  // Define URLs
  const CHARACTER_URL = S3 + "/gaesup.glb";
  const AIRPLANE_URL = S3 + "/air.glb";
  const VEHICLE_URL = S3 + "/kart.glb";
  const WHEEL_URL = S3 + "/wheel.glb";

  return (
    <GaesupWorld
    // ...props defined here
    >
      <Canvas
      // ...props defined here
      >
        <Physics>
          <GaesupController />

          {/* Import Rideable component inside and pass the arguments as shown below */}
          <Rideable
            objectkey="1"
            objectType="vehicle"
            isRiderOn={true}
            url={VEHICLE_URL}
            wheelUrl={WHEEL_URL}
            offset={V3(0, 0.5, 0)}
            position={V3(-10, 5, 10)}
          />
          <Rideable
            objectkey="2"
            objectType="vehicle"
            isRiderOn={false}
            url={VEHICLE_URL}
            wheelUrl={WHEEL_URL}
            position={V3(-20, 5, 10)}
          />
          <Rideable
            objectkey="3"
            objectType="airplane"
            isRiderOn={true}
            url={AIRPLANE_URL}
            offset={V3(0, 0.5, 0)}
            position={V3(10, 5, 10)}
          />
          <Rideable
            objectkey="4"
            objectType="airplane"
            isRiderOn={false}
            url={AIRPLANE_URL}
            position={V3(20, 5, 10)}
          />
        </Physics>
      </Canvas>
    </GaesupWorld>
  );
}

2) Precautions

  • The objectkey must be unique.

3) Props

Prop NameTypeRequiredDescriptionDefault Value
objectkeystringRequiredUnique identifier for the rideable objectNone
objectType"vehicle" or "airplane"OptionalType of the rideable objectundefined
isRiderOnbooleanOptionalWhether a rider is on the rideable objectfalse
urlstringOptional3D model URL for the rideable objectnull
wheelUrlstringOptionalWheel model URL for "vehicle" type rideablesnull
positionTHREE.Vector3OptionalInitial position of the rideable object(0, 0, 0)
rotationTHREE.EulerOptionalInitial rotation angle of the rideable object(0, 0, 0)
offsetTHREE.Vector3OptionalInitial position offset for the rideable object(0, 0, 0)
visiblebooleanOptionalVisibility of the rideable objecttrue
vehicleSizeTHREE.Vector3OptionalSize of the "vehicle" type rideable objectRapier default
wheelSizeTHREE.Vector3OptionalSize of the wheel for "vehicle" type rideablesRapier default
airplaneSizeTHREE.Vector3OptionalSize of the "airplane" type rideable objectRapier default

4) Features

  1. Support for Various Rideable Objects: The Rideable component can render a variety of rideable objects, including "vehicle" and "airplane" types. It can render the 3D models of each object and allow interactions with them.
  2. Customizable Properties: You can easily configure the initial state, size, model URLs, visibility, and more of rideable objects using component properties.
  3. Interaction with Riders: The Rideable component supports interactions required for a rider to board and move with rideable objects.

5) Advantages

  • Modularity and Reusability: The Rideable component is modular and can be easily integrated with other components, increasing code reusability and facilitating maintenance.

  • Rapid Development: By using the useRideable hook, which manages the physics engine and rideable object management, developers can quickly implement and render rideable objects, reducing development time.

  • 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.

  • Flexible Customization: You can customize the appearance and behavior of each rideable object using properties, making it suitable for various game or simulation environments.

Passive


under construct

GaeSupProps


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.

(1) props

The GaeSupProps component accepts the following props:

  • type (optional): A string specifying the type of the prop. It can be either "normal" or "ground". Defaults to "normal" if not provided.
  • 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.
  • 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].
  • 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.

(2) example

  • 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:
import { GaeSupProps } from "./GaeSupProps";

function MyScene() {
  return (
    <GaeSupProps type="normal" text="My Prop" position={[3, 1, -2]}>
      {/* 3D content goes here */}
    </GaeSupProps>
  );
}
  • 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.

(3) Behavior

  • 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.

  • 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

Tools

  • Various tools that assist with character control in GaesupWorld

GameBoy

  • The GameBoy component is a controller interface that emulates GameBoy-like directional buttons. It is primarily intended for mobile usage.

(1) props

Prop NameTypeRequiredDescriptionDefault Value
gamePadStyleobject (styles)OptionalStyle for the GamePad containerundefined
gamePadButtonStyleobject (styles)OptionalStyle for individual GamePad buttonsundefined
labelstringOptionalCustom label for the buttonsundefined

(2) example

import { GameBoy } from "./GameBoy";
import { GaesupWorldContext } from "../../world/context";

const App = () => {
  return (
    <GaesupWorld>
      {/* ... */}
      <GameBoy
        gameboyStyle={gameboyStyle}
        gameboyButtonStyle={gameboyButtonStyle}
      />
      {/* ... */}
    </GaesupWorld>
  );
};

(3) Key Features:

  • Direction Buttons: Implements buttons for directional input (forward, backward, left, right) based on the GameBoyDirections array.
  • Context-aware Rendering: Renders the component based on the mode.controller value from the GaesupWorldContext.
  • Custom Styling: Provides gameboyStyle and gameboyButtonStyle properties for styling customization.

(4) How to Use

To use the GameBoy component:

  1. Place the GameBoy component within your component tree.
  2. Customize the appearance by defining styles in the gameboyStyle and gameboyButtonStyle properties.
  3. The component renders buttons based on the GameBoyDirections array.

GamePad

  • 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.

(1) props

Prop NameTypeRequiredDescriptionDefault Value
gamePadStyleobject (styles)OptionalStyle for the GamePad containerundefined
gamePadButtonStyleobject (styles)OptionalStyle for individual GamePad buttonsundefined
labelstringOptionalCustom label for the buttonsundefined

(2) example

import { GamePad } from "./GamePad";
import { GaesupWorldContext } from "../../world/context";

const App = () => {
  return (
    <GaesupWorld>
      {/* ... */}
      <GamePad
        gamePadStyle={gamePadStyle}
        gamePadButtonStyle={gamePadButtonStyle}
      />
      {/* ... */}
    </GaesupWorld>
  );
};

(3) Key Features

  • Dynamic Button Rendering: Dynamically generates buttons based on the control object in the GaesupWorldContext.
  • Universal Usage: Compatible with various controller modes like joysticks and GameBoys.
  • Custom Styling: Allows customization of the GamePad's appearance using the gamePadStyle and gamePadButtonStyle properties.

(4) How to Use

  1. Include the GamePad component within your component tree.
  2. Customize the appearance using the gamePadStyle and gamePadButtonStyle properties.
  3. The component dynamically renders buttons based on the control mode.

joystick


  • 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.

(1) props

Prop NameTypeRequiredDescriptionDefault Value
joystickStyleobject (styles)OptionalStyle for the joystickundefined
joystickBallStyleobject (styles)OptionalStyle for the joystick ballundefined

(2) example

const MyComponent = () => {
  const joystickStyle = {
    /* joystickStyle */
  };
  const joystickBallStyle = {
    /* joystickBallStyle */
  };

  return (
    <GaesupWorld>
      {/* ... */}
      <joystick
        joystickStyle={joystickStyle}
        joystickBallStyle={joystickBallStyle}
      />
      {/* ... */}
    </GaesupWorld>
  );
};

(3) Key Features:

  • joystick Interface: Provides a joystick-like user input interface, suitable for mobile devices.
  • 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.
  • Responsive and Interactive: It supports various input devices and responds to both mouse and mobile touch events for controlling movement.

4) JumpPortal

  • 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.

(1) props

Prop NameTypeRequiredDescriptionDefault Value
textstringOptionalThe text to display on the portal.undefined
positionTHREE.Vector3RequiredThe target position to teleport to using a THREE.Vector3.None
jumpPortalStyleCSSPropertiesOptionalCSS styles for customizing the appearance of the portal.undefined

(2) example

  • To use the JumpPortal component, you can import it and include it in your React application as follows:
import { JumpPortal } from "./JumpPortal";
import * as THREE from "three";

const App = () => {
  return (
    <GaesupWorld>
      {/* ... */}
      <JumpPortal
        text="Teleport"
        position={new THREE.Vector3(10, 0, 5)}
        jumpPortalStyle={{ backgroundColor: "blue", color: "white" }}
      />
      {/* ... */}
    </GaesupWorld>
  );
};

KeyBoardToolTip


  • The KeyBoardToolTip component is designed to visually represent a keyboard controller interface, providing a visual representation of each key and its associated action.

Key Features

  • Visualizing Keyboard Keys: Visualizes all keyboard keys in an array format.
  • State Animation: Reflects the currently active keys and their associated actions by displaying them differently to provide user feedback.
  • Custom Styling: Provides various styling properties for customizing key caps' appearance.

How to Use

  1. Include the KeyBoardToolTip component within the GaesupWorld component.
  2. Define the control mode as "keyboard" in the mode property.
  3. The component visualizes each keyboard key based on the KeyBoardAll constant and applies different styles for currently active keys.
  4. (Optional) Customize the styles using the keyBoardToolTipInnerStyle, selectedKeyCapStyle, notSelectedkeyCapStyle, and keyCapStyle properties.

Example:

import { KeyBoardToolTip } from "./KeyBoardToolTip";
import { GaesupWorldContext } from "../../world/context";

const App = () => {
  return (
    <GaesupWorld>
      {/* ... */}
      <KeyBoardToolTip
        keyBoardToolTipInnerStyle={keyBoardToolTipInnerStyle}
        selectedKeyCapStyle={selectedKeyCapStyle}
        notSelectedkeyCapStyle={notSelectedkeyCapStyle}
        keyCapStyle={keyCapStyle}
      />
      {/* ... */}
    </GaesupWorld>
  );
};

MiniMap


  • The MiniMap component is used to display a small map of the user's location and the surrounding environment within a 3D world.

(1) props

Prop NameTypeRequiredDescriptionDefault Value
innerStyleobject (styles)OptionalStyle for the inner MiniMap containerundefined
textStyleobject (styles)OptionalStyle for text within the MiniMapundefined
objectStyleobject (styles)OptionalStyle for objects within the MiniMapundefined
avatarStyleobject (styles)OptionalStyle for avatars within the MiniMapundefined
scaleStyleobject (styles)OptionalStyle for the scale control of the MiniMapundefined
directionStyleobject (styles)OptionalStyle for direction indicators in the MiniMapundefined
plusMinusStyleobject (styles)OptionalStyle for plus/minus controls in the MiniMapundefined

2) example

import { MiniMap } from "./MiniMap";

const App = () => {
  return (
    <GaesupWorld>
      {/* ... */}
      <MiniMap
        minimapStyle={minimapStyle}
        innerStyle={innerStyle}
        // Pass other style properties as needed
      />
      {/* ... */}
    </GaesupWorld>
  );
};

3) Key Features

  • Dynamic Scaling: Allows users to dynamically adjust the size of the map.
  • Direction Indicators: Visualizes directions such as East, West, South, and North.
  • Custom Styling: Allows customization of the MiniMap and its internal elements.
  • Mouse Wheel Support: Supports adjusting the map's scale using the mouse wheel.

4) How to Use

  1. Include the MiniMap component within your component tree.
  2. Customize the appearance using the minimapStyle, innerStyle, textStyle, objectStyle, avatarStyle, scaleStyle, directionStyle, and plusMinusStyle properties as needed.
  3. The component updates the MiniMap based on the user's current position and direction.

ZoomButton


  • 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.

(1) props

Prop NameTypeRequiredDescriptionDefault Value
positionTHREE.Vector3RequiredTarget position for the camera to move toNone
childrenReact.ReactNodeOptionalReact nodes to render within the buttonundefined
targetTHREE.Vector3OptionalTarget position for the camera to look atundefined
keepBlockingbooleanOptionalDetermines whether to keep blocking while camera is movingundefined
zoomButtonStyleobject (styles)OptionalStyle for the ZoomButton componentundefined

(2) example

import { ZoomButton } from "./ZoomButton";
import * as THREE from "three";

const App = () => {
  return (
    <GaesupWorld>
      {/* ... */}
      <ZoomButton position={new THREE.Vector3(0, 0, 5)}>{childern}</ZoomButton>
      {/* ... */}
    </GaesupWorld>
  );
};

(3) How to Use

  1. Place the ZoomButton component in your component tree at the desired location.
  2. Define the position prop to specify the location the camera should move to.
  3. When the button is clicked, the camera will move to the specified position.
0.8.45

4 days ago

0.8.47

4 days ago

0.8.46

4 days ago

0.8.44

6 days ago

0.8.4

9 days ago

0.8.41

9 days ago

0.8.43

9 days ago

0.8.42

9 days ago

0.8.36

10 days ago

0.8.35

10 days ago

0.8.38

10 days ago

0.8.37

10 days ago

0.8.39

10 days ago

0.8.3

12 days ago

0.8.34

10 days ago

0.8.32

12 days ago

0.8.31

12 days ago

0.8.23

13 days ago

0.8.22

13 days ago

0.8.25

13 days ago

0.8.24

13 days ago

0.8.27

12 days ago

0.8.26

12 days ago

0.8.29

12 days ago

0.8.28

12 days ago

0.8.2

13 days ago

0.8.21

13 days ago

0.8.12

13 days ago

0.8.14

13 days ago

0.8.13

13 days ago

0.8.19

13 days ago

0.8.16

13 days ago

0.8.15

13 days ago

0.8.18

13 days ago

0.8.17

13 days ago

0.8.1

15 days ago

0.8.11

15 days ago

0.7.95

16 days ago

0.7.94

16 days ago

0.7.92

17 days ago

0.7.91

17 days ago

0.7.33

18 days ago

0.7.4

18 days ago

0.7.9

18 days ago

0.7.5

18 days ago

0.7.8

18 days ago

0.7.7

18 days ago

0.7.32

19 days ago

0.7.31

19 days ago

0.7.2

19 days ago

0.7.1

19 days ago

0.7.3

19 days ago

0.7.0

19 days ago

0.6.9

19 days ago

0.6.8

19 days ago

0.6.87

19 days ago

0.6.86

19 days ago

0.6.89

19 days ago

0.6.88

19 days ago

0.6.83

19 days ago

0.6.82

19 days ago

0.6.85

19 days ago

0.6.81

19 days ago

0.6.79

19 days ago

0.6.62

20 days ago

0.6.7

20 days ago

0.6.76

20 days ago

0.6.75

20 days ago

0.6.78

20 days ago

0.6.77

20 days ago

0.6.72

20 days ago

0.6.74

20 days ago

0.6.73

20 days ago

0.6.61

24 days ago

0.6.58

25 days ago

0.6.57

25 days ago

0.6.6

25 days ago

0.6.54

27 days ago

0.6.53

27 days ago

0.6.56

27 days ago

0.6.55

27 days ago

0.6.52

27 days ago

0.6.51

27 days ago

0.6.5

27 days ago

0.6.4

27 days ago

0.6.34

28 days ago

0.6.33

28 days ago

0.6.35

28 days ago

0.5.7

1 month ago

0.5.9

1 month ago

0.6.31

1 month ago

0.5.6

1 month ago

0.5.5

1 month ago

0.6.3

1 month ago

0.6.1

1 month ago

0.5.4

1 month ago

0.5.3

1 month ago

0.5.2

1 month ago

0.5.1

1 month ago

0.5.21

1 month ago

0.5.22

1 month ago

0.5.23

1 month ago

0.4.4

1 month ago

0.4.3

2 months ago

0.4.2

2 months ago

0.4.1

2 months ago

0.4.0

2 months ago

0.3.7

3 months ago

0.3.6

3 months ago

0.3.5

3 months ago

0.3.2

3 months ago

0.3.4

3 months ago

0.3.3

3 months ago

0.3.0

3 months ago

0.3.1

3 months ago

0.2.6

3 months ago

0.2.52

3 months ago

0.2.51

3 months ago

0.2.27

4 months ago

0.2.26

4 months ago

0.2.25

4 months ago

0.2.24

4 months ago

0.2.23

4 months ago

0.2.22

4 months ago

0.2.21

4 months ago

0.2.37

4 months ago

0.2.36

4 months ago

0.2.35

4 months ago

0.2.34

4 months ago

0.2.33

4 months ago

0.2.32

4 months ago

0.2.31

4 months ago

0.2.1

4 months ago

0.2.0

4 months ago

0.2.29

4 months ago

0.2.28

4 months ago

0.2.3

4 months ago

0.2.2

4 months ago

0.2.5

4 months ago

0.2.4

4 months ago

0.1.4

4 months ago

0.1.3

4 months ago

0.1.0

4 months ago

0.1.2

4 months ago

0.1.1

4 months ago

0.0.783

4 months ago

0.0.782

4 months ago

0.0.781

5 months ago

0.0.772

5 months ago

0.0.771

5 months ago

0.0.77

5 months ago

0.0.769

5 months ago

0.0.768

5 months ago

0.0.766

5 months ago

0.0.73

5 months ago

0.0.765

5 months ago

0.0.74

5 months ago

0.0.764

5 months ago

0.0.75

5 months ago

0.0.763

5 months ago

0.0.76

5 months ago

0.0.767

5 months ago

0.0.762

5 months ago

0.0.761

5 months ago

0.0.71

5 months ago

0.0.72

5 months ago

0.0.7

5 months ago

0.0.692

5 months ago

0.0.69

5 months ago

0.0.691

5 months ago

0.0.62

5 months ago

0.0.63

5 months ago

0.0.64

5 months ago

0.0.653

5 months ago

0.0.65

5 months ago

0.0.66

5 months ago

0.0.67

5 months ago

0.0.68

5 months ago

0.0.663

5 months ago

0.0.652

5 months ago

0.0.662

5 months ago

0.0.651

5 months ago

0.0.661

5 months ago

0.0.3

5 months ago

0.0.2

5 months ago

0.0.5

5 months ago

0.0.4

5 months ago

0.0.61

5 months ago

0.0.6

5 months ago

0.0.1

5 months ago