Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

modecs

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

modecs

Small, fast, data-oriented, runtime-composable ECS library.

  • 0.1.11
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

🌌 ModECS 🌌

Small, fast, data-oriented, runtime-composable ECS library written in JavaScript.

Features

  • ~5 KB gzipped
  • Classless ES6
  • Performance focused
  • Runtime composable
  • Promotes reusability

Planned

  • Topological ordering of system loops based on component type dependencies
  • Serializable state (all the way down to systems & their update functions)
  • External store adapters
  • V programming language port with Node bindings to the same API

Install

npm i modecs

Example

const ModECS = require('modecs')
const engine = ModECS()

// register components with a name and shape
engine.registerComponent('POSITION', { x: 0, y: 0 })
engine.registerComponent('TARGET', { x: 0, y: 0 })

engine.registerSystem(
  // name of the system
  'Movement',
  // component types required by the system
  ['POSITION','TARGET'],
  // a setup function to initialize the system with (happens once)
  () => {
    const speed = 10

    // return the update function to be called every tick
    // position and target components, as well as the entityId they exist on are injected
    return (position, target, entityId) => {
      position.x += target.x * speed * engine.time.delta
      position.y += target.y * speed * engine.time.delta
    }
  }
)

// createEntity returns a new ID
const entityID1 = engine.createEntity()
engine.addEntity(entityID1)

const entityID2 = engine.createEntity()
engine.addEntity(entityID2) // must add entity to the engine before adding components

// add components to an ID with a name and shape
engine.addComponent(entityID2, 'POSITION', { x: 50 })
engine.addComponent(entityID2, 'TARGET', { x: 1, y: 1 }) // entity2 will move southeast

engine.start()

Check out the Introduction for more details.

FAQs

Package last updated on 11 Aug 2019

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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc