• Content Count

  • Joined

  • Last visited

Everything posted by cmann

  1. @ozdy I've updated nape.max.js in github I had scripts that generated the nape js files, but can't remember how they work (it's a bit of a mess), so I just manually copy/pasted the necessary defineProperty lines from another copy I had Hopefully this should fix the problem for you.
  2. Ok so I think I found the problem. Some of those constants have get_XXX function, then use defineProperty to link that function to the property name, eg. for BodyType.STATIC // There's a function like this BodyType.get_STATIC = function() { ... }; // Then lower down there's this: Object.defineProperty(BodyType, "STATIC", {get: BodyType.get_STATIC}); Now for some reason (I'm have no idea how) some of those defineProperty calls were removed or possibly never added. The thing is that to get nape working in js was a lot of work - I had to convert it from haxe to js, then had to do a lot of processing to get that working so it's possible I screwed something up at some point without realising it. I quick fix could be to directly use the get_ functions instead, eg. // Instead of this CbEvent.BEGIN // Use this CbEvent.get_BEGIN()
  3. Strange. This is what I get: So just to confirm, you're using nape.min.js, or nape.max.js from here:
  4. Honestly I haven't looked at this in a while, but I'll try to help. If you use the following for example, what output do you get? console.log(nape.callbacks.CbEvent.BEGIN); console.log(nape.callbacks.CbType.ANY_BODY); console.log(nape.phys.BodyType.DYNAMIC);
  5. A small update: I've added a rag doll demo. As expected Nape and Box2D handle this without a problem. It was also simple to do in p2.js but it falls behind a bit in performance with a large number of rag dolls. I could hack something together that's close to a rag doll in MatterJs, but neither that nor PhysicsJs really has the required features to make it work properly.
  6. I've made some changes, added a demo comparing the various constraints each library offers, and, as you suggested, created a github repo. You can find it here: And view it online here:
  7. No problem. I've never used github or anything similar before but I might just try that. I may also add a few more tests and make it easier to create tests without having to hand write code for each engine.
  8. What physics engines are available for Javascript and/or Typescript? I've searched myself but maybe there's one or two I missed. I also found a post in these forums but that's over two years old now; It's a little disappointing to see that some of them aren't actively developed and lacking a lot of features. I put together a test to compare the different engines I tried - I've attached the files if anyone wants to try it out. Here are the engines I've tried: PhysicsJs - Incomplete: lacking simple features like constraints - Seems like it was last updated 2 years ago - Possibly the worst performance - Strange API (in my opinion) and difficult to use - Built in mouse interaction behaves strangely MatterJs - Also incomplete and lacking constraints - Has a built in mouse constraint but it acts strangely - Updated recently - Simple and easy to use - Doesn't handle stress test well p2.js - Complete - Updated within the last few months - Doesn't handle stress test well - Easy to use - Good documentation Box2DWeb - Complete - everything you would expect from Box2D - Last updated one or two years ago - Semi-poor documentation - you have use the box2d flash documentation which is fairly thorough but slightly outdated - Much faster and a lot more accurate than the above three libraries. Nape - Complete - lots of features - but isn't very active - Has a great marching squares utility which can convert bitmaps into polygons - Good site and documentation - Easy to use but the pooling get/dispose stuff can be a bit confusing - Similar (or maybe even slight better) performance to Box2DWeb and possibly more accurate - Large - minified it's still 1.7MB The one problem with Nape though is that it isn't really meant for Javascript and I had a lot of trouble getting it set up in Typescript. There were some project to convert it to js and generate definition files but I had to modify them a lot to get something complete that worked for me. I also had to manually convert the debug draw classes from as3 to js and Easeljs. Luckily that only needs to be done once - after that I didn't have any problems using it though. I also tried PhysicsType2D ( but couldn't get it to work. Overall I was a bit disappointed; In terms of performance, the 'native' js libraries fell short by a lot compared to the two ported ones, and on top of that they lacked a lot of important features. Even the ported ones didn't perform as well as their Flash/As3 versions - the Nape stress test (you can find it here) which I copied, runs significantly better in flash. UPDATE: You can find the updated github repo here:
  9. I thought so. The thing is that I have a raw texture that I'm updating dynamically so I'd like to combine the diffuse and specular map into a single texture so that I don't have to update two separate textures. Is the only alternative to create my own texture/shader?
  10. Is it possible, using the standard material, to specify that the diffuse texture alpha channel should be used to control the specular value?