[New Port] JSBox2D! Release 2.3.1.r3

Discuss issues specific the Javascript port of Box2D
ttt
Posts: 10
Joined: Thu Dec 19, 2013 1:42 pm

Re: [New Port] JSBox2D! Release 2.3.1.r3

Postby ttt » Sat Dec 28, 2013 9:01 am

Paril wrote:I provide a Canvas-based draw in the root of the trunk you can look at.
r3 now provides a module-based build; by default, if 'window' is there, it will define window.b2 to be the Box2D namespace (ie, b2.Vec2, b2.World, etc). If you create a global var named "b2_compatibility", it will instead use the old global method.

Which methods are missing?

-P


well the methods missing are:


debugDraw.SetDrawScale(2)
debugDraw.SetSprite(ctx);
debugDraw.SetDrawScale(scale);
debugDraw.SetFillAlpha(fillAlpha);
debugDraw.SetAlpha(globalAlpha);
debugDraw.SetLineThickness(0);
debugDraw.SetFlags(
Box2D.DebugDraw.e_shapeBit |
Box2D.DebugDraw.e_jointBit
// Box2D.DebugDraw.e_aabbBit |
// Box2D.DebugDraw.e_centerOfMassBit |
// Box2D.DebugDraw.e_controllerBit |
// Box2D.DebugDraw.e_pairBit
);

I'm using those in the previous version and in the 2.3 doesn't work.

Also, I don't know if you can, is to still maintain a hierarchy version of Box2D:
For example assign a variable to your b2 variable named: originalBox2D that keeps things in hierarchy like this:

instead of b2.Point to be b2.originalBox2D.Collision.b2Point; Why that? because b2Separator (subdivide non convex in convex shapes) requires a hierarchy object.

Anyway thanks for your contribution, even if I can't make use of it, yet.

Do you have a problem with not properly deleting bodies? viewtopic.php?f=22&t=9595

Paril
Posts: 236
Joined: Mon Jul 27, 2009 6:46 am

Re: [New Port] JSBox2D! Release 2.3.1.r3

Postby Paril » Sat Dec 28, 2013 11:54 am

Most of those are not required any more/were left over from the old system. Check out my CanvasDebug.js which provides my replacement for the old web Box2D draw.

I don't want to maintain a fake hierarchy. It's not the way Box2D C++ is, and doing so would make it harder to type with & more difficult to use. I provide two setups right now: b2Vec2 and b2.Vec2. Doing b2.Common.Math.Vec2 is too verbose and not necessary. It would also reduce runtime efficiency by a huge amount.

The old ports have a lot of problems. That problem isn't in this one.

-P

ttt
Posts: 10
Joined: Thu Dec 19, 2013 1:42 pm

Re: [New Port] JSBox2D! Release 2.3.1.r3

Postby ttt » Sun Dec 29, 2013 6:50 am

Paril wrote:Most of those are not required any more/were left over from the old system. Check out my CanvasDebug.js which provides my replacement for the old web Box2D draw.

I don't want to maintain a fake hierarchy. It's not the way Box2D C++ is, and doing so would make it harder to type with & more difficult to use. I provide two setups right now: b2Vec2 and b2.Vec2. Doing b2.Common.Math.Vec2 is too verbose and not necessary. It would also reduce runtime efficiency by a huge amount.

The old ports have a lot of problems. That problem isn't in this one.

-P


Well the fake hierarchy is needed for plugins that use the fake hierarchy. I don't like it neither but the plugin doesn't work if there is no hierarchy.

Well your Box2D also seems to be leaking memory (hope not, hope I'm doing it bad): try doing this in google chrome:
- Then open your profile and make a snapshot.
- Now run the c() method in your console to create 100 bodies
- Now snapshot 2
- Search in snapshot for b2Body and you'll find 1000 Object count
- Now run d() to delete all your bodies;
- Force Garbage collection by clicking on the garbage can
- Make a snapshot 3
- Search for b2Body and you'll also find 1000 Object count

Add this code to a file in
var gravity = new Box2D.Vec2(0, 0);
var doSleep = true;
var world = new Box2D.World(gravity, doSleep);

var bodies = []
window.c = function(){
for(var i = 0; i < 1000; i++){
var bodyDef = new Box2D.BodyDef();
bodyDef.type = 2;

var shape = new Box2D.PolygonShape();
shape.SetAsBox(1, 1);

var fixtureDef = new Box2D.FixtureDef();
fixtureDef.shape = shape;
var body = world.CreateBody(bodyDef);
body._id = i;
body.CreateFixture(fixtureDef);
bodies.push(body);
}
console.log('Created', bodies)
}
window.d = function(){
_.each(bodies, function(body, i){
world.DestroyBody(body);
bodies[i] = null;
})
bodies = null;
}


I've asked here a question about this: http://stackoverflow.com/questions/2081 ... 2-1-a-3-js

ttt
Posts: 10
Joined: Thu Dec 19, 2013 1:42 pm

Re: [New Port] JSBox2D! Release 2.3.1.r3

Postby ttt » Wed Jan 15, 2014 6:50 am

Paril wrote:Most of those are not required any more/were left over from the old system. Check out my CanvasDebug.js which provides my replacement for the old web Box2D draw.

I don't want to maintain a fake hierarchy. It's not the way Box2D C++ is, and doing so would make it harder to type with & more difficult to use. I provide two setups right now: b2Vec2 and b2.Vec2. Doing b2.Common.Math.Vec2 is too verbose and not necessary. It would also reduce runtime efficiency by a huge amount.

The old ports have a lot of problems. That problem isn't in this one.

-P

where is your CanvasDebug.js?

TriBlade9
Posts: 1
Joined: Tue Jun 03, 2014 7:30 pm

Re: [New Port] JSBox2D! Release 2.3.1.r3

Postby TriBlade9 » Tue Jun 03, 2014 7:43 pm

From this topic, This looks really great!
I'm currently using box2dweb for my project, but I'd prefer to use a newer port.

However, I live in China, and at the moment, China's firewall is blocking code.google.com. (And everything else google)

Would someone mind making a GitHub (or other public SVN repository) mirror for people who cannot access Google Code?

Thank you.

dmagunov
Posts: 1
Joined: Wed Nov 26, 2014 3:36 pm

Re: [New Port] JSBox2D! Release 2.3.1.r3

Postby dmagunov » Wed Nov 26, 2014 3:40 pm

Paril wrote:Hey there, guys.

I was pretty disappointed at the lack of a decent JS port of Box2D, so I decided to give myself a crack at it as I have a good use for it.
You can follow development & download here: https://code.google.com/p/jsbox2d

It is based off of the latest trunk version of Box2D.
Current release is JSBox2D 2.3.1.r3

-P


Hello Paril,

Please, check my implementation of jsbox2d loader for RUBE scene:

Source code: https://github.com/dmagunov/Argadnet/tr ... ed/jsbox2d
Demo: http://argadnet.com/demo/rube_testbed/j ... index.html
Blog post about it: http://argadnet.com/jsbox2d-port-of-box ... -action_5/

jefferific
Posts: 1
Joined: Tue Sep 08, 2015 8:50 am

Re: [New Port] JSBox2D! Release 2.3.1.r3

Postby jefferific » Tue Sep 08, 2015 8:56 am

Paril: I've recently been learning Box2D in Cocos2d-JS, and after using the included version of box2dweb for awhile, I discovered your more updated Box2D port. On the Google Code page for JSBox2D, it says it also includes LiquidFun -- but when I download the source I don't see any of the b2Particle classes in it. Am I missing something?

Thanks in advance for your help. I'm very appreciative of your efforts to bring an updated version of Box2D to those of us targeting the browser.

davidjohnson789
Posts: 5
Joined: Wed Mar 23, 2016 10:07 pm

Re: [New Port] JSBox2D! Release 2.3.1.r3

Postby davidjohnson789 » Wed Mar 23, 2016 10:43 pm

Thank you for your post.
i also have the problem about JSBox2D! Release 2.3.1.r3


Return to “Javascript”



Who is online

Users browsing this forum: No registered users and 1 guest