1

I want to use Box2D-Web with Meteorjs on both client and server side. I used this in nodejs. There was a small configuration that exports Box2D variable, and it was working with nodejs. The additional configuration was exports.Box2D = Box2D; at the bottom of the libary.

But I couldn't load it in meteor. I put the Box2D-web under lib directory in my project. But it gives an error and I still don't see what the problem is.

Here is what meteor saying;

W20140106-00:15:03.627(2)? (STDERR) /Users/ahmetdal/workspace/realhaxtmp/.meteor/local/build/programs/server/boot.js:186
W20140106-00:15:03.692(2)? (STDERR) }).run();
W20140106-00:15:03.692(2)? (STDERR)    ^
W20140106-00:15:03.692(2)? (STDERR) TypeError: Cannot call method 'write' of undefined
W20140106-00:15:03.693(2)? (STDERR)     at Console.log (console.js:53:16)
W20140106-00:15:03.694(2)? (STDERR)     at Object.Meteor._debug (packages/meteor/debug.js:41)
W20140106-00:15:03.694(2)? (STDERR)     at _.extend.publish (packages/livedata/livedata_server.js:1166)
W20140106-00:15:03.694(2)? (STDERR)     at app/server/publications.js:7:12
W20140106-00:15:03.694(2)? (STDERR)     at /Users/ahmetdal/workspace/realhaxtmp/.meteor/local/build/programs/server/boot.js:159:61
W20140106-00:15:03.694(2)? (STDERR)     at Array.forEach (native)
W20140106-00:15:03.694(2)? (STDERR)     at Function._.each._.forEach (/Users/ahmetdal/.meteor/tools/09b63f1ed5/lib/node_modules/underscore/underscore.js:79:11)
W20140106-00:15:03.695(2)? (STDERR)     at /Users/ahmetdal/workspace/realhaxtmp/.meteor/local/build/programs/server/boot.js:159:5

There is not error about the Box2D-Web library. I tried to find any alternative meaning for the error but, I could not find anything either.

This error is being occurred when I put the library under lib folder under project root.

I did not put all code of library here. Because it really consists of too many lines of codes.

What additional configration in library can I do to apply it to Meteorjs?

Thank you!

Ahmet DAL
  • 4,445
  • 9
  • 47
  • 71
  • Meteor is crashing as soon as I add box2d. My guess from looking at their code is that, since they declare a lot to global variables, if one of those globals is named as one of meteor's then they just crash the whole thing. – Cristian Garcia Apr 21 '14 at 05:45
  • What are some good reference for Box2d-Web? – Doug Hauf Jun 26 '14 at 18:44

1 Answers1

0

Placing Javascript files like the Box2D-Web library in the lib folder in the root of your project will cause the code to be run on both the client and the server. The error occurs when the library gets run on the server.

To fix this, just place the library file into /client/lib/.

justswim
  • 944
  • 9
  • 8
  • Actually I want to use it on server side because of server side game simulation. This is why I put it under lib folder. I need it on both client and server side. – Ahmet DAL Jan 06 '14 at 06:36
  • Hmm, I must have misread your question. I'm not sure about the error in this case .. please let me know if you find a solution! – justswim Jan 07 '14 at 09:00