Comparing version 0.0.6 to 0.1.0
{ | ||
"name": "bitecs", | ||
"version": "0.0.6", | ||
"version": "0.1.0", | ||
"description": "Tiny, data-driven, high performance ECS library written in Javascript", | ||
"main": "index.js", | ||
"type": "module", | ||
"main": "./dist/index.min.js", | ||
"module": "./dist/index.es.js", | ||
"author": { | ||
"name": "Nathaniel Martin", | ||
"email": "mrtn.nathaniel@gmail.com", | ||
"url": "http://n8bit.io/" | ||
}, | ||
"contributors": [ | ||
{ | ||
"name": "Randy Lebeau", | ||
"email": "randylebeau@gmail.com", | ||
"url": "https://github.com/SupremeTechnopriest" | ||
} | ||
], | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
"build": "rollup -c", | ||
"test": "jest", | ||
"docs": "node scripts/docs.js", | ||
"dist": "npm run test && npm run build && npm run docs" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/NateTheGreatt/bitecs.git" | ||
"devDependencies": { | ||
"@babel/preset-env": "^7.12.1", | ||
"@rollup/plugin-babel": "^5.2.1", | ||
"dmd-readable": "SupremeTechnopriest/dmd-readable", | ||
"globby": "^11.0.1", | ||
"jest": "^26.6.1", | ||
"jsdoc-to-markdown": "^6.0.1", | ||
"rollup": "^2.32.1", | ||
"rollup-plugin-terser": "^7.0.2" | ||
}, | ||
"keywords": [ | ||
"ecs", | ||
"game", | ||
"performance", | ||
"data-driven" | ||
], | ||
"author": "Nathaniel Martin", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/NateTheGreatt/bitecs/issues" | ||
"babel": { | ||
"presets": [ | ||
[ | ||
"@babel/preset-env", | ||
{ | ||
"targets": { | ||
"node": "current" | ||
} | ||
} | ||
] | ||
] | ||
}, | ||
"homepage": "https://github.com/NateTheGreatt/bitecs#readme" | ||
"jest": { | ||
"testMatch": [ | ||
"**/__tests__/**/*.test.js" | ||
] | ||
} | ||
} |
@@ -7,5 +7,5 @@ # 👾 bitECS 👾 | ||
- `<3kb` gzipped | ||
- zero dependencies | ||
- node or browser | ||
- [_fast_](https://github.com/NateTheGreatt/bitECS/blob/master/examples/benchmark.js) | ||
- Zero dependencies | ||
- Node or Browser | ||
- [_Fast_](https://github.com/noctjs/ecs-benchmark) | ||
@@ -18,72 +18,43 @@ ## Install | ||
## Example | ||
```javascript | ||
// imports a factory function | ||
import bitECS from 'bitECS' | ||
// define the max number of entities in the ecs | ||
const n = 1000000 | ||
```js | ||
import World from 'bitecs' | ||
// create a new ECS and destruct desirable functions | ||
const { | ||
addEntity, | ||
addComponent, | ||
removeComponent, | ||
registerComponent, | ||
registerSystem, | ||
update | ||
} = bitECS(n) | ||
// Create a world | ||
const world = World() | ||
// register components | ||
const Vector3 = { x: 'float32', y: 'float32', z: 'float32' } // nested structures are fully supported | ||
registerComponent('position', Vector3) | ||
registerComponent('velocity', Vector3) | ||
// Register some components | ||
world.registerComponent('POSITION', { x: 'float32', y: 'float32' }) | ||
world.registerComponent('VELOCITY', { vx: 'int8', vy: 'int8', speed: 'uint16' }) | ||
// register a movement system | ||
registerSystem({ | ||
name: 'movement', | ||
// update will only apply to these components | ||
// in this case entities with both a position & velocity component will be processed | ||
components: ['position', 'velocity'], | ||
// update function provides component managers and the entity ID to do work on | ||
update: (pos, vel) => eid => { | ||
// entity data is obtained from the respective component managers | ||
// managers are objects with typedarray properties | ||
// this is how high performance is reaped and maintained | ||
pos.x[eid] += vel.x[eid] | ||
pos.y[eid] += vel.y[eid] | ||
pos.z[eid] += vel.z[eid] | ||
}, | ||
// called whenever an entity is added to the system (has required components) | ||
onEnter: (pos, vel) => eid => {}, | ||
// called whenever an entity is removed from the system (no longer has required components) | ||
onExit: (pos, vel) => eid => {}, | ||
// called once, before the system update (not per entity, no eid passed in) | ||
onBefore: (pos, vel) => {}, | ||
// called once, after the system update | ||
onAfter: (pos, vel) => {}, | ||
// called per entity, before the system updates it | ||
onBeforeEach: (pos, vel) => eid => {}, | ||
// called per entity, after the system updates it | ||
onAfterEach: (pos, vel) => eid => {} | ||
// Register a system | ||
world.registerSystem({ | ||
name: 'MOVEMENT', | ||
components: ['POSITION', 'VELOCITY'], | ||
update: (position, velocity) => eid => { | ||
position.x[eid] += velocity.vx[eid] * velocity.speed[eid] | ||
position.y[eid] += velocity.vy[eid] * velocity.speed[eid] | ||
} | ||
}) | ||
// Create an entity | ||
const eid = world.addEntity() | ||
// create n entities with random position and velocity | ||
for(let i = 0; i < n; i++) { | ||
let eid = addEntity() | ||
addComponent('position', eid, {x: Math.random(), y: Math.random(), z: Math.random()}) | ||
addComponent('velocity', eid, {x: Math.random(), y: Math.random(), z: Math.random()}) | ||
} | ||
// Add components to entity | ||
world.addComponent('POSITION', eid, { x: 100, y: 100 }) | ||
world.addComponent('VELOCITY', eid, { vx: 1, vy: -1, speed: 100 }) | ||
// node | ||
// Create an event loop and step world | ||
setInterval(() => { | ||
update() | ||
}, 16) // yes, this ECS can process one million entities in under 16ms (depending on the CPU) | ||
world.step() | ||
}, 1000 / 30) // 30 tick on server | ||
// browser | ||
// For browser, use frame rate | ||
const loop = () => { | ||
requestAnimationFrame(loop) | ||
update() | ||
world.step() | ||
requestAnimationFrame(loop) | ||
} | ||
loop() | ||
``` | ||
``` | ||
Full documentation and feature rich examples can be found [here](DOCS.md). |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 20 instances in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
25707876
26
8
299
1
58
3
21
No