Socket
Book a DemoInstallSign in
Socket

bitecs

Package Overview
Dependencies
Maintainers
1
Versions
133
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bitecs

Functional, minimal, data-driven, ultra-high performance ECS library written in Javascript

0.3.18
Source
npmnpm
Version published
Weekly downloads
4.1K
61.26%
Maintainers
1
Weekly downloads
Ā 
Created
Source

šŸ‘¾ 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-benchmarkddmills/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)

šŸ”Œ Powering

FAQs

Package last updated on 24 Aug 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with āš”ļø by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.