GithubHelp home page GithubHelp logo

flyover / box2d.ts Goto Github PK

View Code? Open in Web Editor NEW
402.0 402.0 83.0 17.65 MB

A TypeScript port of Box2D

Home Page: https://flyover.github.io/box2d.ts/testbed

License: MIT License

TypeScript 84.92% HTML 0.14% Makefile 0.07% JavaScript 14.87%

box2d.ts's People

Contributors

finscn avatar flyover avatar nek- avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

box2d.ts's Issues

ERROR: `Cannot find name 'Set'.`

When I run tsc , I got many errors:

Controllers/b2Controller.ts(44,31): error TS2304: Cannot find name 'Set'.
Controllers/b2Controller.ts(44,31): error TS4031: Public property 'm_bodyList' of exported class has or is using private name 'Set'.
Controllers/b2Controller.ts(44,59): error TS2304: Cannot find name 'Set'.
Controllers/b2Controller.ts(66,25): error TS2304: Cannot find name 'Set'.
Controllers/b2Controller.ts(66,25): error TS4055: Return type of public method from exported class has or is using private name 'Set'.
Dynamics/b2Body.ts(185,34): error TS2304: Cannot find name 'Set'.
Dynamics/b2Body.ts(185,34): error TS4031: Public property 'm_fixtureList' of exported class has or is using private name 'Set'.
Dynamics/b2Body.ts(185,55): error TS2304: Cannot find name 'Set'.
Dynamics/b2Body.ts(187,32): error TS2304: Cannot find name 'Set'.
Dynamics/b2Body.ts(187,32): error TS4031: Public property 'm_jointList' of exported class has or is using private name 'Set'.
Dynamics/b2Body.ts(187,55): error TS2304: Cannot find name 'Set'.
Dynamics/b2Body.ts(188,34): error TS2304: Cannot find name 'Set'.
Dynamics/b2Body.ts(188,34): error TS4031: Public property 'm_contactList' of exported class has or is using private name 'Set'.
Dynamics/b2Body.ts(188,59): error TS2304: Cannot find name 'Set'.
Dynamics/b2Body.ts(206,37): error TS2304: Cannot find name 'Set'.
Dynamics/b2Body.ts(206,37): error TS4031: Public property 'm_controllerList' of exported class has or is using private name 'Set'.
Dynamics/b2Body.ts(206,65): error TS2304: Cannot find name 'Set'.
Dynamics/b2Body.ts(988,28): error TS2304: Cannot find name 'Set'.
Dynamics/b2Body.ts(988,28): error TS4055: Return type of public method from exported class has or is using private name 'Set'.
Dynamics/b2Body.ts(993,26): error TS2304: Cannot find name 'Set'.
Dynamics/b2Body.ts(993,26): error TS4055: Return type of public method from exported class has or is using private name 'Set'.
Dynamics/b2Body.ts(1000,28): error TS2304: Cannot find name 'Set'.
Dynamics/b2Body.ts(1000,28): error TS4055: Return type of public method from exported class has or is using private name 'Set'.
Dynamics/b2Body.ts(1117,31): error TS2304: Cannot find name 'Set'.
Dynamics/b2Body.ts(1117,31): error TS4055: Return type of public method from exported class has or is using private name 'Set'.
Dynamics/b2ContactManager.ts(31,34): error TS2304: Cannot find name 'Set'.
Dynamics/b2ContactManager.ts(31,34): error TS4031: Public property 'm_contactList' of exported class has or is using private name 'Set'.
Dynamics/b2ContactManager.ts(31,55): error TS2304: Cannot find name 'Set'.
Dynamics/b2World.ts(69,31): error TS2304: Cannot find name 'Set'.
Dynamics/b2World.ts(69,31): error TS4031: Public property 'm_bodyList' of exported class has or is using private name 'Set'.
Dynamics/b2World.ts(69,49): error TS2304: Cannot find name 'Set'.
Dynamics/b2World.ts(70,32): error TS2304: Cannot find name 'Set'.
Dynamics/b2World.ts(70,32): error TS4031: Public property 'm_jointList' of exported class has or is using private name 'Set'.
Dynamics/b2World.ts(70,51): error TS2304: Cannot find name 'Set'.
Dynamics/b2World.ts(73,41): error TS2304: Cannot find name 'Set'.
Dynamics/b2World.ts(73,41): error TS4031: Public property 'm_particleSystemList' of exported class has or is using private name 'Set'.
Dynamics/b2World.ts(73,69): error TS2304: Cannot find name 'Set'.
Dynamics/b2World.ts(100,37): error TS2304: Cannot find name 'Set'.
Dynamics/b2World.ts(100,37): error TS4031: Public property 'm_controllerList' of exported class has or is using private name 'Set'.
Dynamics/b2World.ts(100,61): error TS2304: Cannot find name 'Set'.
Dynamics/b2World.ts(740,25): error TS2304: Cannot find name 'Set'.
Dynamics/b2World.ts(740,25): error TS4055: Return type of public method from exported class has or is using private name 'Set'.
Dynamics/b2World.ts(747,26): error TS2304: Cannot find name 'Set'.
Dynamics/b2World.ts(747,26): error TS4055: Return type of public method from exported class has or is using private name 'Set'.
Dynamics/b2World.ts(752,35): error TS2304: Cannot find name 'Set'.
Dynamics/b2World.ts(752,35): error TS4055: Return type of public method from exported class has or is using private name 'Set'.
Dynamics/b2World.ts(762,28): error TS2304: Cannot find name 'Set'.
Dynamics/b2World.ts(762,28): error TS4055: Return type of public method from exported class has or is using private name 'Set'.
Particle/b2ParticleSystem.ts(644,37): error TS2304: Cannot find name 'Set'.
Particle/b2ParticleSystem.ts(1031,34): error TS2304: Cannot find name 'Set'.
Particle/b2ParticleSystem.ts(1031,34): error TS4055: Return type of public method from exported class has or is using private name 'Set'.

sleeping bodies wake on aabb collision

sleeping bodies wake up when their bounding box collides with another fixture's bounding box, rather than on the actual fixture shapes colliding - is this intentional? (it's not consistent with the behaviour of the flash version of box2d I am porting a game from)

error

TS4073: Parameter 'proxy' of public method from exported class has or is using private name 'b2DistanceProxy'.

Some errors when build

Collision/Shapes/b2Shape.ts(19,31): error TS6133: 'XY' is declared but its value is never read.
Common/b2Draw.ts(19,10): error TS6133: 'b2Vec2' is declared but its value is never read.
Dynamics/b2Fixture.ts(20,31): error TS6133: 'XY' is declared but its value is never read.

Is there a reason why `position` and `linearVelocity` are readonly on b2BodyDef?

I'm working on loading up the physics data from JSON. I noticed that both position and linearVelocity are defined as readonly in b2BodyDef. Is there a reason for this? It seems odd, since in b2Body it does set the value based on the b2BodyDef values for position and linearVelocity, respectively. This more or less makes it effectively the default values.

Or am I missing something?

changes needed for babel typescript combo

babel typescript does not support "const enum" and "namespace"
removing const from enum and also
refactoring the names in the namespace areas or moving them to their own module is needed to make it compatible.

Recommended way to add to project?

This isn't really a "bug". I was curious the best way to add this to a project. I'm currently getting starting with Typescript and webpack.

I have a rough prototype working where I simply added the script (box2d.umd.js) to my index.html file.

However, as there is no declaration file, it seems like it would be better off directly adding the source into my project? I notice all the exports are in the Box2D.ts file. Whereas within Typescript I think you can include a directory by using an index.ts file.

Is there a recommended way to add into a project?

Why use many extra function-call in b2Math.ts

example:

export class b2Mat22 {
  public static AbsM(M: b2Mat22, out: b2Mat22): b2Mat22 { return b2AbsM(M, out); }
}

function b2AbsM(M: b2Mat22, out: b2Mat22): b2Mat22 {
  const M_ex: b2Vec2 = M.ex, M_ey: b2Vec2 = M.ey;
  out.ex.x = b2Abs(M_ex.x);
  out.ex.y = b2Abs(M_ex.y);
  out.ey.x = b2Abs(M_ey.x);
  out.ey.y = b2Abs(M_ey.y);
  return out;
}

Why don't you use :

export class b2Mat22 {
  public static AbsM(M: b2Mat22, out: b2Mat22): b2Mat22 {
    const M_ex: b2Vec2 = M.ex, M_ey: b2Vec2 = M.ey;
    out.ex.x = b2Abs(M_ex.x);
    out.ex.y = b2Abs(M_ex.y);
    out.ey.x = b2Abs(M_ey.x);
    out.ey.y = b2Abs(M_ey.y);
    return out;
 }
}

const b2AbsM = b2Mat22.AbsM;

[Suggestion]Use `es5` as default compile target.

When use es5 , user could use the dist js file in browser more easily.

Share my tsconfig.json

{
  "compilerOptions": {
    "target": "es5",
    "module": "system",
    "strict": true,
    "strictNullChecks": false,
    "inlineSourceMap": false,
    "preserveConstEnums": true,
    "noImplicitAny": true,
    "noImplicitReturns": true,
    "noImplicitThis": true,
    "noImplicitUseStrict": false,
    "noUnusedLocals": true,
    "noUnusedParameters": false,
    "removeComments": true,
    "sourceMap": true,
    "inlineSources": false,
    "declaration": true,
    "outFile": "../../dist/box2d-ts.js"
  },
  "include": [
    "**/*.ts"
  ]
}

user could use box2d-ts.js with system-production.js in browser (and mobile browser) directly.

[Question] How to make sleeping bodies interact with sensors?

Hi, this question is about the same game I was talking about in #46

TL;DR (#46)
a top-down online game, rectangle-shaped sensor body around the player used to register objects in the world that shoud be sent to that player.

I faced the following problem: When the screen stops intersecting with a coin (and moves far away from it), sometimes the contact object is still there, it is still active and still thinks that it is touching.

Screen is a static body with a box shaped sensor. This body is moved to the player position on every tick.

A coin is a sleeping dynamic body with a circle shape.

What can cause this?

create/set DebugDraw

Tell me please.
How can I implement and add DebugDraw through the abstract class b2Draw?

[Question] Keep existing contacts on shape updates

Hi, I am making a top-down view multiplayer game and I have a lot of objects on my map. The map is bigger than the player's screen, so one player can only see a part of a map.

When I am sending updates to the player I want to send him only the objects he can see to prevent him from cheating by zooming out. The most convenient solution that I found was to create a screen-sized sensor shape around the player. When this sensor begins a contact with an object, this means the player can see it and I can send it to the client. When the contact ends this means that the object disappeared from the player's screen and should be removed from the client's state.

This was a perfect solution, which saved me from storing arrays of everything a player can see and compare it with the new one on every tick to find what was added/removed from the screen. But, unfortunately player field of view can change over time. Shapes can't be updated in box2d. This means i have to delete an old screen shape and create a new one. When this happens, every contact with this shape is deleted and created again. Is there a solution for this case? Bodies involved in this contact didn't change, only their shapes did. What i want here is to track contacts by bodies not by shapes. I don't need any normals or something, only a boolean are they still touching or not.

LICENSE Needed !

Hello,

I figure out that even if this project is open source, you didn't put any license. Also as there is already many contributors it's already a problem.

Contributors have rights on license choice. So I recommend you to add one ASAP.

Notice that I'm in favor of MIT :).

@finscn also need to give his though on this

position changes when collision occurs in a special environment.

this does not exist on PC, our environment is a special one, if you use Chian shap to make a wall, and when a dynamic box hits it, the box will 'bounce' back once.

in my code:
gravity: 9.8
box's linear velocity on horizontal is set to 4
road: whatever line shape or chain shap
others are all default value

here is the test video:
https://jc-space.com/test/v.mp4

as you can see, when the box hits the wall, it will be 'dragged' back (from x: 7.6 to 6.8) , and then move forward again (because I set linearvelocity in a loop), then back again, then loop again...

because this does not exist on PC and I'm not familiar with the principle of physics engine, so I have no idea at all what can cause this problem, float precision?? please help to analyze, thanks so much! this is really critical for us!

@flyover @finscn

Didn't work for vs code

after compilation in VS code I get 2 thousand warnings (typescript 2.4.2)
Please, help me.

ts/Box2D/Particle/b2ParticleSystem.ts[3760, 15]: expected variable-declaration: 'vb' to have a typedef
ts/Box2D/Particle/b2ParticleSystem.ts[3766, 14]: expected variable-declaration: 'd' to have a typedef

ts/Box2D/Particle/b2ParticleSystem.ts[4763, 3]: The class method 'GetNext' must be marked either 'private', 'public', or 'protected'
ts/Box2D/Particle/b2ParticleSystem.ts[4784, 3]: The class property 'list' must be marked either 'private', 'public', or 'protected'
ts/Box2D/Particle/b2ParticleSystem.ts[4788, 3]: The class property 'next' must be marked either 'private', 'public', or 'protected'
ts/Box2D/Particle/b2ParticleSystem.ts[4793, 3]: The class property 'count' must be marked either 'private', 'public', or 'protected'
ts/Box2D/Particle/b2ParticleSystem.ts[4797, 3]: The class property 'index' must be marked either 'private', 'public', or 'protected'

ts/Box2D/Dynamics/Joints/b2MotorJoint.ts[108, 27]: expected call-signature: 'GetAngularOffset' to have a typedef
ts/Box2D/Dynamics/Joints/b2MotorJoint.ts[117, 22]: expected call-signature: 'GetMaxForce' to have a typedef
ts/Box2D/Dynamics/Joints/b2MotorJoint.ts[126, 23]: expected call-signature: 'GetMaxTorque' to have a typedef
ts/Box2D/Dynamics/Joints/b2MotorJoint.ts[219, 52]: expected member-variable-declaration: 'SolveVelocityConstraints_s_Cdot_v2' to have a typedef
ts/Box2D/Dynamics/Joints/b2MotorJoint.ts[220, 55]: expected member-variable-declaration: 'SolveVelocityConstraints_s_impulse_v2' to have a typedef

ts/Box2D/Dynamics/Joints/b2PulleyJoint.ts[395, 9]: " should be '
ts/Box2D/Dynamics/Joints/b2PulleyJoint.ts[396, 9]: " should be '
ts/Box2D/Dynamics/Joints/b2PulleyJoint.ts[397, 9]: " should be '
ts/Box2D/Dynamics/Joints/b2PulleyJoint.ts[398, 9]: " should be '

Todos?

How much of box2d is ported and how much is left to do? Is there a todo list or maybe stubs in the code? It would be really nice to have a todo list, to be able to continue working on the project and to compare to other ports (there are already too many, of varying completeness and quality).

Really like what you have done this far. Is this a manual port? Maybe semi-automatic?

Strange build errors

Hello!

I'm getting build errors when I go to use box2d.ts in an Ionic project of mine. I've installed @flyover/box2d.ts via NPM.

The build errors I get don't seem to match the code I'm examining, and there are probably a hundred or more of them.

screen shot 2018-10-19 at 11 45 39

I'm aware there aren't this many errors in the library - there are none when I clone and build testbed on its own - but do you have any advice? I haven't seen this when using any other dependencies, so I'm stumped!

Thanks

Could someone publish a new npm package from the current version of the project?

Could someone publish a new npm package from the current version. The current npm package appears to be broken since when I try to compile my project that uses box2d.ts npm package I get a type error in b2ParticleSystem.ts in function std_lower_bound<A, B>(array: A[], first: number, last: number, val: B, cmp: (a: A, b: B) => boolean = default_compare) where the error is probably caused because default_compare cannot be assigned to type (a:A, b: B) => boolean since it is of type <T> (a: T, b: T) => boolean. In the current version this seems to be fixed.

Thanks in advance.

Can't compile via tsc

There are some errors :

Collision/b2BroadPhase.ts(111,16): error TS1251: Function declarations are not allowed inside blocks in strict mode when targeting 'ES3' or 'ES5'. Class definitions are automatically in strict mode.

Collision/b2DynamicTree.ts(655,9): error TS6133: 'freeCount' is declared but its value is never read.

Dynamics/b2Body.ts(308,9): error TS6133: 'found' is declared but its value is never read.

Particle/b2ParticleSystem.ts(4527,9): error TS6133: 'discarded' is declared but its value is never read.

about pre-build definitions

// #if B2_ENABLE_PARTICLE

is there some options in Rollup or somewhere to make this take effect?
for example defines: { B2_ENABLE_PARTICLE: false }
then the code in this section will be ignored when compiling?

thanks.

Buffers not flattened?

In the original liquidfun emscripten port from google, the buffers (such as GetPositionBuffer(), GetColorBuffer() etc.) are returned as flattened arrays of sequential data so it can be efficiently fed to a shader. (ie. positionBuffer[0] is X of the first particle, positionBuffer[1] is Y of the first particle)

In your port (which is fantastic, btw) you return arrays of objects with .x and .y properties instead.
Is there a reason you chose to make this change? Do you know if there is a performance hit / benefit?

Do you have a plane to Change the name of API ?

@flyover , Hi ,
Do you have a plane to Change the name of API , then provide a JavaScript-friendly API ?

example:
box2d.b2BodyDef --> Box2d.bodyDef
world.CreateBody --> world.createBody
b2BodyType.b2_dynamicBody --> bodyType.dynamicBody
...

the things https://github.com/shakiba/planck.js do :

  • b2 prefix is dropped from class names, for example b2World is now available as planck.World.
  • Method names are converted from UpperCamelCase to lowerCamelCase.
  • Definition classes/objects (BodyDef, FixtureDef, etc.) are replaced by inline JavaScript objects ({}).
  • Shapes are made immutable and are not cloned when used to create fixtures.
  • World#on(eventName, listenerFn) and World#off(eventName, listenerFn) are added to add and remove event listeners. Currently supported events are:
    • 'begin-contact'
    • 'end-contact'
    • 'pre-solve'
    • 'post-solve'
    • 'joint-removed'
    • 'fixture-removed'
    • `'body-removed'

Bad performance with `kinematic body`

I create a demo 'Tumbler' for testing performance .

And I found a strange thing.

When I use kinematic body to the Tumbler outbox , the performance is bad.
http://fatidol.com/phy-benchmark/box2d-ts-test.html?type=kinematic
(40 FPS on my macbook)

When I use dynamic body + revolute joint to the Tumbler outbox , the performance is better.
http://fatidol.com/phy-benchmark/box2d-ts-test.html
(60 FPS on my macbook)

This result puzzles me :
When & How should I use kinematic ?

Suggestion: open a gitter chat

Gitter is a nice place for open source projects. Chatting may avoid us to create issues and can be productive. It may also allow people to know better each other. What do you think about dropping a link to a gitter chat?

Error on tsc build

Errors are emitted as below on typescript version 3.1.3

node_modules/box2d.ts/Box2D/Particle/b2ParticleSystem.ts(102,81): error TS2322: Type '<T>(a: T, b: T) => boolean' is not assignable to type '(a: A, b: B) => boolean'.
  Types of parameters 'b' and 'b' are incompatible.
    Type 'B' is not assignable to type 'A'.
node_modules/box2d.ts/Box2D/Particle/b2ParticleSystem.ts(118,81): error TS2322: Type '<T>(a: T, b: T) => boolean' is not assignable to type '(a: A, b: B) => boolean'.
  Types of parameters 'b' and 'b' are incompatible.
    Type 'B' is not assignable to type 'A'.

Velocity resets to zero when small constant force is applied

Hello,

I have encountered a strange bug. When I apply a small force (that causes acceleration lower than 0.02) to a dynamic body, instead of linear acceleration it periodically accelerates for a while and than the velocity gets reset back to zero:

Mass: 0.9176
Force: Vector { x: 0.001, y: 0 }

Current velocity: Vector { x: 0, y: 0 }
Current velocity: Vector { x: 0.000021795989537925027, y: 0 }
Current velocity: Vector { x: 0.000043591979075850053, y: 0 }
Current velocity: Vector { x: 0.00006538796861377507, y: 0 }
Current velocity: Vector { x: 0.00008718395815170011, y: 0 }
Current velocity: Vector { x: 0.00010897994768962514, y: 0 }
Current velocity: Vector { x: 0.00013077593722755017, y: 0 }
Current velocity: Vector { x: 0.0001525719267654752, y: 0 }
Current velocity: Vector { x: 0.00017436791630340024, y: 0 }
Current velocity: Vector { x: 0.00019616390584132527, y: 0 }
Current velocity: Vector { x: 0.0002179598953792503, y: 0 }
Current velocity: Vector { x: 0.00023975588491717534, y: 0 }
Current velocity: Vector { x: 0.00026155187445510035, y: 0 }
Current velocity: Vector { x: 0.0002833478639930254, y: 0 }
Current velocity: Vector { x: 0.0003051438535309504, y: 0 }
Current velocity: Vector { x: 0.00032693984306887545, y: 0 }
Current velocity: Vector { x: 0.0003487358326068005, y: 0 }
Current velocity: Vector { x: 0.0003705318221447255, y: 0 }
Current velocity: Vector { x: 0.00039232781168265055, y: 0 }
Current velocity: Vector { x: 0.0004141238012205756, y: 0 }
Current velocity: Vector { x: 0.0004359197907585006, y: 0 }
Current velocity: Vector { x: 0.00045771578029642565, y: 0 }
Current velocity: Vector { x: 0.0004795117698343507, y: 0 }
Current velocity: Vector { x: 0.0005013077593722757, y: 0 }
Current velocity: Vector { x: 0.0005231037489102007, y: 0 }
Current velocity: Vector { x: 0, y: 0 }
Current velocity: Vector { x: 0.000021795989537925027, y: 0 }
Current velocity: Vector { x: 0.000043591979075850053, y: 0 }
Current velocity: Vector { x: 0.00006538796861377507, y: 0 }
Current velocity: Vector { x: 0.00008718395815170011, y: 0 }
Current velocity: Vector { x: 0.00010897994768962514, y: 0 }
Current velocity: Vector { x: 0.00013077593722755017, y: 0 }
Current velocity: Vector { x: 0.0001525719267654752, y: 0 }
Current velocity: Vector { x: 0.00017436791630340024, y: 0 }
Current velocity: Vector { x: 0.00019616390584132527, y: 0 }
Current velocity: Vector { x: 0.0002179598953792503, y: 0 }
Current velocity: Vector { x: 0.00023975588491717534, y: 0 }
Current velocity: Vector { x: 0.00026155187445510035, y: 0 }
Current velocity: Vector { x: 0.0002833478639930254, y: 0 }
Current velocity: Vector { x: 0.0003051438535309504, y: 0 }
Current velocity: Vector { x: 0.00032693984306887545, y: 0 }
Current velocity: Vector { x: 0.0003487358326068005, y: 0 }
Current velocity: Vector { x: 0.0003705318221447255, y: 0 }
Current velocity: Vector { x: 0.00039232781168265055, y: 0 }
Current velocity: Vector { x: 0.0004141238012205756, y: 0 }
Current velocity: Vector { x: 0.0004359197907585006, y: 0 }
Current velocity: Vector { x: 0.00045771578029642565, y: 0 }
Current velocity: Vector { x: 0.0004795117698343507, y: 0 }
Current velocity: Vector { x: 0.0005013077593722757, y: 0 }
Current velocity: Vector { x: 0.0005231037489102007, y: 0 }
Current velocity: Vector { x: 0, y: 0 }
Current velocity: Vector { x: 0.000021795989537925027, y: 0 }
Current velocity: Vector { x: 0.000043591979075850053, y: 0 }
Current velocity: Vector { x: 0.00006538796861377507, y: 0 }
Current velocity: Vector { x: 0.00008718395815170011, y: 0 }
Current velocity: Vector { x: 0.00010897994768962514, y: 0 }
Current velocity: Vector { x: 0.00013077593722755017, y: 0 }
Current velocity: Vector { x: 0.0001525719267654752, y: 0 }
Current velocity: Vector { x: 0.00017436791630340024, y: 0 }
Current velocity: Vector { x: 0.00019616390584132527, y: 0 }
Current velocity: Vector { x: 0.0002179598953792503, y: 0 }
Current velocity: Vector { x: 0.00023975588491717534, y: 0 }
Current velocity: Vector { x: 0.00026155187445510035, y: 0 }
Current velocity: Vector { x: 0.0002833478639930254, y: 0 }
Current velocity: Vector { x: 0.0003051438535309504, y: 0 }
Current velocity: Vector { x: 0.00032693984306887545, y: 0 }
Current velocity: Vector { x: 0.0003487358326068005, y: 0 }
Current velocity: Vector { x: 0.0003705318221447255, y: 0 }
Current velocity: Vector { x: 0.00039232781168265055, y: 0 }
Current velocity: Vector { x: 0.0004141238012205756, y: 0 }
Current velocity: Vector { x: 0.0004359197907585006, y: 0 }
Current velocity: Vector { x: 0.00045771578029642565, y: 0 }
Current velocity: Vector { x: 0.0004795117698343507, y: 0 }
Current velocity: Vector { x: 0.0005013077593722757, y: 0 }
Current velocity: Vector { x: 0.0005231037489102007, y: 0 }
Current velocity: Vector { x: 0, y: 0 }

When the acceleration is greater than 0.02 (approximately), dynamic body accelerates as expected.

Here is the only mention of this bug (related to Box2d) that I have found on the web:
http://discuss.cocos2d-x.org/t/cocos2d-x-3-17-physicsbody-applyforce-still-works-wrong/42631
https://discuss.cocos2d-x.org/t/cocos2d-x-3-16-physicsworld-weird/39518

b2ContactPoint

hi, I wonder is there a corresponding class in this lib for b2ContactPoint? I can't find it.

DrawShape implementation differs from C++ version

Not sure if people have been implementing debug drawing through b2Draw but it looks like there is some deviation. For example, there is no PushTransform or PopTransform. It seems that in order to properly render the objects, one needs to apply the transforms.

Is this deliberate?

Source code can't be compiled.

image

function default_compare<T>(a: T, b: T): boolean { return a < b; }

the error is

[ts]
cant assign “(a: A, b: B) => boolean” to “(a: T, b: T) => boolean”
arg “b” is not compatible with “b”
cant assign “B” to type “A”

[RFC] Build configuration

Hello,

Opening PRs about build configuration leads to conflicts, hard rebases and then be forgotten... I think it's a good idea to discuss about the build policy.

Here is what I recommend. Please comment if you disagree with args about so I can understand and maybe suggest something else:

  1. Change the build of the Testbed
    • Build in a separated folder Box2D/Testbed/dist
    • With webpack
    • Drop systemjs
    • Use the package instead of the code of Box2D available in the same repository directly
    • Means having its own package.json file (as well as tsconfig.json, so it makes sense)
  2. Remove js files everywhere
    • There is so many files in the code base; research is a mess because of duplication in folders
    • Presence of JS files above the TS one make no sense
  3. Build Box2D.js with module: es2015 / moduleResolution: node
    • This is the most used configuration
    • With declarations: true and specify declaration as typings
    • The folder will be dist/Box2D
  4. Build a single file with webpack concat or the configuration of tsconf.json if possible
    • Located in dist/Box2D.dev.js
    • And dist/Box2D.min.js

Please give feedbacks on these points.

Please notice that for the moment I use a custom configuration because your package does not work for me. Here is my branch with this config: https://github.com/Nek-/box2d.ts/tree/feature/many-output

[Share Your Project] Project Showcase

Project Showcase

If you're using box2d.ts for your game then make a comment below with a link to the github repo & the website!

Even if your game or application has just started - post a link! It will be nice to see how people are using this version of box2d.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.