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

0g-box2d

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

0g-box2d - npm Package Compare versions

Comparing version 0.0.3 to 0.0.4

dist-esm/components.d.ts

2

dist-esm/index.d.ts
export * as systems from './systems';
export * as stores from './stores';
export * as components from './components';
export type { EntityContact } from './ContactListener';
export * from './constants';
export * from './types';
import * as systems_1 from './systems';
export { systems_1 as systems };
import * as stores_1 from './stores';
export { stores_1 as stores };
import * as components_1 from './components';
export { components_1 as components };
export * from './constants';
export * from './types';
//# sourceMappingURL=index.js.map

@@ -28,3 +28,3 @@ var __extends = (this && this.__extends) || (function () {

import { ContactListener } from './ContactListener';
import * as stores from './stores';
import * as components from './components';
import { createCapsule } from './utils';

@@ -95,31 +95,31 @@ function assignBodyConfig(body, config, id) {

_this.newWorlds = _this.query({
all: [stores.WorldConfig],
none: [stores.World],
all: [components.WorldConfig],
none: [components.World],
});
_this.worlds = _this.query({
all: [stores.World],
all: [components.World],
none: [],
});
_this.bodies = _this.query({
all: [stores.Body, stores.Transform],
all: [components.Body, components.Transform],
none: [],
});
_this.bodiesWithContacts = _this.query({
all: [stores.Contacts, stores.ContactsCache],
all: [components.Contacts, components.ContactsCache],
none: [],
});
_this.newBodies = _this.query({
all: [stores.BodyConfig, stores.Transform],
none: [stores.Body],
all: [components.BodyConfig, components.Transform],
none: [components.Body],
});
_this.oldBodies = _this.query({
all: [stores.Body],
none: [stores.BodyConfig],
all: [components.Body],
none: [components.BodyConfig],
});
_this.initWorlds = _this.frame(_this.newWorlds, function (worldEntity) {
var worldConfig = worldEntity.get(stores.WorldConfig);
_this.initWorlds = _this.step(_this.newWorlds, function (worldEntity) {
var worldConfig = worldEntity.get(components.WorldConfig);
var w = new b2World(worldConfig.gravity);
var c = new ContactListener();
w.SetContactListener(c);
worldEntity.add(stores.World, {
worldEntity.add(components.World, {
value: w,

@@ -129,3 +129,3 @@ contacts: c,

});
_this.initBodies = _this.frame(_this.newBodies, function (bodyEntity) {
_this.initBodies = _this.step(_this.newBodies, function (bodyEntity) {
if (!_this.defaultWorld) {

@@ -136,4 +136,4 @@ // TODO: overkill?

}
var bodyConfig = bodyEntity.get(stores.BodyConfig);
var transform = bodyEntity.get(stores.Transform);
var bodyConfig = bodyEntity.get(components.BodyConfig);
var transform = bodyEntity.get(components.Transform);
var b = _this.defaultWorld.value.CreateBody();

@@ -145,28 +145,28 @@ var x = transform.x, y = transform.y, angle = transform.angle;

applyFixtures(b, createFixtureDef(bodyConfig, bodyEntity.id));
bodyEntity.add(stores.Body, {
bodyEntity.add(components.Body, {
value: b,
});
// subscribe contacts if present
var contacts = bodyEntity.maybeGet(stores.Contacts);
var contacts = bodyEntity.maybeGet(components.Contacts);
if (contacts) {
bodyEntity.add(stores.ContactsCache);
var contactsCache = bodyEntity.get(stores.ContactsCache);
bodyEntity.add(components.ContactsCache);
var contactsCache = bodyEntity.get(components.ContactsCache);
_this.defaultWorld.contacts.subscribe(bodyEntity.id, contactsCache);
}
});
_this.updateBodies = _this.watch(_this.bodies, [stores.BodyConfig], function (entity) {
var bodyConfig = entity.get(stores.BodyConfig);
var body = entity.get(stores.Body);
_this.updateBodies = _this.watch(_this.bodies, [components.BodyConfig], function (entity) {
var bodyConfig = entity.get(components.BodyConfig);
var body = entity.get(components.Body);
assignBodyConfig(body.value, bodyConfig, entity.id);
applyFixtures(body.value, createFixtureDef(bodyConfig, entity.id));
});
_this.teardownBodies = _this.frame(_this.oldBodies, function (bodyEntity) {
_this.teardownBodies = _this.step(_this.oldBodies, function (bodyEntity) {
if (!_this.defaultWorld)
return;
var body = bodyEntity.get(stores.Body);
var body = bodyEntity.get(components.Body);
_this.defaultWorld.value.DestroyBody(body.value);
_this.defaultWorld.contacts.unsubscribe(bodyEntity.id);
});
_this.resetContacts = _this.frame(_this.bodiesWithContacts, function (bodyEntity) {
var contacts = bodyEntity.get(stores.Contacts);
_this.resetContacts = _this.step(_this.bodiesWithContacts, function (bodyEntity) {
var contacts = bodyEntity.get(components.Contacts);
contacts.set({

@@ -177,10 +177,10 @@ began: [],

});
_this.stepWorlds = _this.frame(_this.worlds, function (worldEntity) {
var world = worldEntity.get(stores.World);
var worldConfig = worldEntity.get(stores.WorldConfig);
_this.stepWorlds = _this.step(_this.worlds, function (worldEntity) {
var world = worldEntity.get(components.World);
var worldConfig = worldEntity.get(components.WorldConfig);
world.value.Step(1 / 60.0, worldConfig.velocityIterations, worldConfig.positionIterations);
});
_this.updateTransforms = _this.frame(_this.bodies, function (bodyEntity) {
var transform = bodyEntity.get(stores.Transform);
var body = bodyEntity.get(stores.Body);
_this.updateTransforms = _this.step(_this.bodies, function (bodyEntity) {
var transform = bodyEntity.get(components.Transform);
var body = bodyEntity.get(components.Body);
var pos = body.value.GetPosition();

@@ -194,6 +194,6 @@ transform.set({

// update contacts
_this.updateContacts = _this.frame(_this.bodiesWithContacts, function (bodyEntity) {
_this.updateContacts = _this.step(_this.bodiesWithContacts, function (bodyEntity) {
var e_1, _a, e_2, _b;
var cached = bodyEntity.getWritable(stores.ContactsCache);
var contacts = bodyEntity.getWritable(stores.Contacts);
var cached = bodyEntity.getWritable(components.ContactsCache);
var contacts = bodyEntity.getWritable(components.Contacts);
var c;

@@ -244,3 +244,3 @@ try {

var _a;
return (_a = this.defaultWorldEntity) === null || _a === void 0 ? void 0 : _a.get(stores.World);
return (_a = this.defaultWorldEntity) === null || _a === void 0 ? void 0 : _a.get(components.World);
},

@@ -247,0 +247,0 @@ enumerable: false,

export * as systems from './systems';
export * as stores from './stores';
export * as components from './components';
export type { EntityContact } from './ContactListener';
export * from './constants';
export * from './types';

@@ -25,7 +25,7 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.stores = exports.systems = void 0;
exports.components = exports.systems = void 0;
exports.systems = __importStar(require("./systems"));
exports.stores = __importStar(require("./stores"));
exports.components = __importStar(require("./components"));
__exportStar(require("./constants"), exports);
__exportStar(require("./types"), exports);
//# sourceMappingURL=index.js.map

@@ -50,3 +50,3 @@ "use strict";

var ContactListener_1 = require("./ContactListener");
var stores = __importStar(require("./stores"));
var components = __importStar(require("./components"));
var utils_1 = require("./utils");

@@ -117,31 +117,31 @@ function assignBodyConfig(body, config, id) {

_this.newWorlds = _this.query({
all: [stores.WorldConfig],
none: [stores.World],
all: [components.WorldConfig],
none: [components.World],
});
_this.worlds = _this.query({
all: [stores.World],
all: [components.World],
none: [],
});
_this.bodies = _this.query({
all: [stores.Body, stores.Transform],
all: [components.Body, components.Transform],
none: [],
});
_this.bodiesWithContacts = _this.query({
all: [stores.Contacts, stores.ContactsCache],
all: [components.Contacts, components.ContactsCache],
none: [],
});
_this.newBodies = _this.query({
all: [stores.BodyConfig, stores.Transform],
none: [stores.Body],
all: [components.BodyConfig, components.Transform],
none: [components.Body],
});
_this.oldBodies = _this.query({
all: [stores.Body],
none: [stores.BodyConfig],
all: [components.Body],
none: [components.BodyConfig],
});
_this.initWorlds = _this.frame(_this.newWorlds, function (worldEntity) {
var worldConfig = worldEntity.get(stores.WorldConfig);
_this.initWorlds = _this.step(_this.newWorlds, function (worldEntity) {
var worldConfig = worldEntity.get(components.WorldConfig);
var w = new box2d_1.b2World(worldConfig.gravity);
var c = new ContactListener_1.ContactListener();
w.SetContactListener(c);
worldEntity.add(stores.World, {
worldEntity.add(components.World, {
value: w,

@@ -151,3 +151,3 @@ contacts: c,

});
_this.initBodies = _this.frame(_this.newBodies, function (bodyEntity) {
_this.initBodies = _this.step(_this.newBodies, function (bodyEntity) {
if (!_this.defaultWorld) {

@@ -158,4 +158,4 @@ // TODO: overkill?

}
var bodyConfig = bodyEntity.get(stores.BodyConfig);
var transform = bodyEntity.get(stores.Transform);
var bodyConfig = bodyEntity.get(components.BodyConfig);
var transform = bodyEntity.get(components.Transform);
var b = _this.defaultWorld.value.CreateBody();

@@ -167,28 +167,28 @@ var x = transform.x, y = transform.y, angle = transform.angle;

applyFixtures(b, createFixtureDef(bodyConfig, bodyEntity.id));
bodyEntity.add(stores.Body, {
bodyEntity.add(components.Body, {
value: b,
});
// subscribe contacts if present
var contacts = bodyEntity.maybeGet(stores.Contacts);
var contacts = bodyEntity.maybeGet(components.Contacts);
if (contacts) {
bodyEntity.add(stores.ContactsCache);
var contactsCache = bodyEntity.get(stores.ContactsCache);
bodyEntity.add(components.ContactsCache);
var contactsCache = bodyEntity.get(components.ContactsCache);
_this.defaultWorld.contacts.subscribe(bodyEntity.id, contactsCache);
}
});
_this.updateBodies = _this.watch(_this.bodies, [stores.BodyConfig], function (entity) {
var bodyConfig = entity.get(stores.BodyConfig);
var body = entity.get(stores.Body);
_this.updateBodies = _this.watch(_this.bodies, [components.BodyConfig], function (entity) {
var bodyConfig = entity.get(components.BodyConfig);
var body = entity.get(components.Body);
assignBodyConfig(body.value, bodyConfig, entity.id);
applyFixtures(body.value, createFixtureDef(bodyConfig, entity.id));
});
_this.teardownBodies = _this.frame(_this.oldBodies, function (bodyEntity) {
_this.teardownBodies = _this.step(_this.oldBodies, function (bodyEntity) {
if (!_this.defaultWorld)
return;
var body = bodyEntity.get(stores.Body);
var body = bodyEntity.get(components.Body);
_this.defaultWorld.value.DestroyBody(body.value);
_this.defaultWorld.contacts.unsubscribe(bodyEntity.id);
});
_this.resetContacts = _this.frame(_this.bodiesWithContacts, function (bodyEntity) {
var contacts = bodyEntity.get(stores.Contacts);
_this.resetContacts = _this.step(_this.bodiesWithContacts, function (bodyEntity) {
var contacts = bodyEntity.get(components.Contacts);
contacts.set({

@@ -199,10 +199,10 @@ began: [],

});
_this.stepWorlds = _this.frame(_this.worlds, function (worldEntity) {
var world = worldEntity.get(stores.World);
var worldConfig = worldEntity.get(stores.WorldConfig);
_this.stepWorlds = _this.step(_this.worlds, function (worldEntity) {
var world = worldEntity.get(components.World);
var worldConfig = worldEntity.get(components.WorldConfig);
world.value.Step(1 / 60.0, worldConfig.velocityIterations, worldConfig.positionIterations);
});
_this.updateTransforms = _this.frame(_this.bodies, function (bodyEntity) {
var transform = bodyEntity.get(stores.Transform);
var body = bodyEntity.get(stores.Body);
_this.updateTransforms = _this.step(_this.bodies, function (bodyEntity) {
var transform = bodyEntity.get(components.Transform);
var body = bodyEntity.get(components.Body);
var pos = body.value.GetPosition();

@@ -216,6 +216,6 @@ transform.set({

// update contacts
_this.updateContacts = _this.frame(_this.bodiesWithContacts, function (bodyEntity) {
_this.updateContacts = _this.step(_this.bodiesWithContacts, function (bodyEntity) {
var e_1, _a, e_2, _b;
var cached = bodyEntity.getWritable(stores.ContactsCache);
var contacts = bodyEntity.getWritable(stores.Contacts);
var cached = bodyEntity.getWritable(components.ContactsCache);
var contacts = bodyEntity.getWritable(components.Contacts);
var c;

@@ -266,3 +266,3 @@ try {

var _a;
return (_a = this.defaultWorldEntity) === null || _a === void 0 ? void 0 : _a.get(stores.World);
return (_a = this.defaultWorldEntity) === null || _a === void 0 ? void 0 : _a.get(components.World);
},

@@ -269,0 +269,0 @@ enumerable: false,

{
"name": "0g-box2d",
"version": "0.0.3",
"version": "0.0.4",
"description": "box2d plugin for 0g",

@@ -5,0 +5,0 @@ "files": [

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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