Giter Site home page Giter Site logo

jacksonfrankland / bitecs Goto Github PK

View Code? Open in Web Editor NEW

This project forked from natethegreatt/bitecs

0.0 0.0 0.0 769 KB

Functional, minimal, data-oriented, ultra-high performance ECS library written in JavaScript

License: Mozilla Public License 2.0

JavaScript 100.00%

bitecs's Introduction

๐Ÿ‘พ bitECS ๐Ÿ‘พ npm Minzipped npm License

Functional, minimal, data-oriented, ultra-high performance ECS library written using JavaScript TypedArrays.

โœจ Features

๐Ÿ”ฎ Simple, declarative API ๐Ÿ”ฅ Blazing fast iteration
๐Ÿ” Powerful & performant queries ๐Ÿ’พ Serialization included
๐Ÿƒ Zero dependencies ๐ŸŒ Node or browser
๐Ÿค <5kb minzipped ๐Ÿท TypeScript support
โค Made with love ๐Ÿ”บ glMatrix support

๐Ÿ“ˆ Benchmarks

๐Ÿš€ Unparalleled performance benchmarks

noctjs/ecs-benchmark ddmills/js-ecs-benchmarks

๐Ÿ’ฟ Install

npm i bitecs

๐Ÿ“˜ Documentation

๐Ÿ Getting Started
๐Ÿ“‘ API
โ” FAQ

๐Ÿ•น Example

import {
  createWorld,
  Types,
  defineComponent,
  defineQuery,
  addEntity,
  addComponent,
  defineSystem,
  pipe,
} from 'bitecs'

const Vector3 = { x: Types.f32, y: Types.f32, z: Types.f32 }
const Position = defineComponent(Vector3)
const Velocity = defineComponent(Vector3)

const movementQuery = defineQuery([Position, Velocity])

const movementSystem = defineSystem((world) => {
  const ents = movementQuery(world)
  for (let i = 0; i < ents.length; i++) {
    const eid = ents[i]
    Position.x[eid] += Velocity.x[eid]
    Position.y[eid] += Velocity.y[eid]
    Position.z[eid] += Velocity.z[eid]
  }
})

const timeSystem = defineSystem(world => {
  const { time } = world
  const now = performance.now()
  const delta = now - time.then
  time.delta = delta
  time.elapsed += delta
  time.then = now
})

const pipeline = pipe(movementSystem, timeSystem)

const world = createWorld()
world.time = { delta: 0, elapsed: 0, then: performance.now() }

const eid = addEntity(world)
addComponent(world, Position, eid)
addComponent(world, Velocity, eid)

setInterval(() => {
  pipeline(world)
}, 16)

bitecs's People

Contributors

natethegreatt avatar ooflorent avatar supremetechnopriest avatar robertlong avatar dependabot[bot] avatar endershadow8 avatar juliangarnier avatar worbunkel avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.