All Projects → PrismarineJS → prismarine-physics

PrismarineJS / prismarine-physics

Licence: MIT license
Provide the physics engine for minecraft entities

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to prismarine-physics

Webots
Webots Robot Simulator
Stars: ✭ 1,324 (+5416.67%)
Mutual labels:  physics-engine
Simbody
High-performance C++ multibody dynamics/physics library for simulating articulated biomechanical and mechanical systems like vehicles, robots, and the human skeleton.
Stars: ✭ 1,808 (+7433.33%)
Mutual labels:  physics-engine
P2.js
JavaScript 2D physics library
Stars: ✭ 2,367 (+9762.5%)
Mutual labels:  physics-engine
Physics3d
A 3D physics engine
Stars: ✭ 101 (+320.83%)
Mutual labels:  physics-engine
Visual Interaction Networks tensorflow
Tensorflow Implementation of Visual Interaction Networks
Stars: ✭ 133 (+454.17%)
Mutual labels:  physics-engine
Physac
2D physics header-only library for videogames developed in C using raylib library.
Stars: ✭ 151 (+529.17%)
Mutual labels:  physics-engine
Cubbyflow V1
Voxel-based fluid simulation engine for computer games
Stars: ✭ 90 (+275%)
Mutual labels:  physics-engine
3D interactive graphics rendering engine
Develop a 3D interactive graphics rendering engine
Stars: ✭ 31 (+29.17%)
Mutual labels:  physics-engine
Jelloswift
Swift soft body physics engine
Stars: ✭ 134 (+458.33%)
Mutual labels:  physics-engine
Hand tracking samples
👋 👌 research codebase for depth-based hand pose estimation using dynamics based tracking and CNNs
Stars: ✭ 180 (+650%)
Mutual labels:  physics-engine
Nphysics
2 and 3-dimensional rigid body physics engine for Rust.
Stars: ✭ 1,530 (+6275%)
Mutual labels:  physics-engine
Elm Physics
3D physics engine in Elm
Stars: ✭ 132 (+450%)
Mutual labels:  physics-engine
Cubbyflow
Voxel-based fluid simulation engine for computer games
Stars: ✭ 151 (+529.17%)
Mutual labels:  physics-engine
Micro Racing
🚗 🏎️ 🎮 online 3D multiplayer neural networks based racing game
Stars: ✭ 100 (+316.67%)
Mutual labels:  physics-engine
Box2d
Box2D.go - Go port of Box2D - a 2D Physics Engine for Games.
Stars: ✭ 208 (+766.67%)
Mutual labels:  physics-engine
Specs Physics
nphysics integration for the Specs entity component system
Stars: ✭ 94 (+291.67%)
Mutual labels:  physics-engine
Matter Js
a 2D rigid body physics engine for the web ▲● ■
Stars: ✭ 12,522 (+52075%)
Mutual labels:  physics-engine
crystal-chipmunk
Crystal bindings to Chipmunk, a fast and lightweight 2D game physics library
Stars: ✭ 38 (+58.33%)
Mutual labels:  physics-engine
voxel-physics-engine
Simple but physical engine for voxels. Demo:
Stars: ✭ 59 (+145.83%)
Mutual labels:  physics-engine
Haskellspritekit
Haskell binding to Apple's SpriteKit framework
Stars: ✭ 165 (+587.5%)
Mutual labels:  physics-engine

prismarine-physics

NPM version Build Status Discord Gitter Irc

Try it on gitpod

Provide the physics engine for minecraft entities

Usage

const { Physics, PlayerState } = require('prismarine-physics')
const { Vec3 } = require('vec3')

const mcData = require('minecraft-data')('1.13.2')
const Block = require('prismarine-block')('1.13.2')

const physics = Physics(mcData, world)
const controls = {
  forward: false,
  back: false,
  left: false,
  right: false,
  jump: false,
  sprint: false,
  sneak: false
}
const player = {
    entity: {
      position: pos,
      velocity: new Vec3(0, 0, 0),
      onGround: false,
      isInWater: false,
      isInLava: false,
      isInWeb: false,
      isCollidedHorizontally: false,
      isCollidedVertically: false,
      yaw: 0
    },
    jumpTicks: 0,
    jumpQueued: false
  }
const playerState = new PlayerState(player, controls)

while (!player.entity.onGround) {
  // simulate 1 tick of player physic, then apply the result to the player
  physics.simulatePlayer(playerState, world).apply(player)
}

See examples/ for more.

API

Physics

simulatePlayer(playerState, world)

  • playerState : instance of the PlayerState class
  • world : interface with a function getBlock(position) returning the prismarine-block at the given position

PlayerState

A player state is an object containing the properties:

Read / Write properties:

  • pos : position (vec3) of the player entity
  • vel : velocity (vec3) of the player entity
  • onGround : (boolean) is the player touching ground ?
  • isInWater : (boolean) is the player in water ?
  • isInLava : (boolean) is the player in lava ?
  • isInWeb : (boolean) is the player in a web ?
  • isCollidedHorizontally : (boolean) is the player collided horizontally with a solid block ?
  • isCollidedVertically : (boolean) is the player collided vertically with a solid block ?
  • jumpTicks : (integer) number of ticks before the player can auto-jump again
  • jumpQueued : (boolean) true if the jump control state was true between the last tick and the current one

Read only properties:

  • yaw : (float) the yaw angle, in radians, of the player entity
  • control : (object) control states vector with properties:
    • forward
    • back
    • left
    • right
    • jump
    • sprint
    • sneak
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].