Open DanielHZhang opened 3 years ago
Check out https://github.com/Lusito/box2d.ts/blob/master/packages/benchmark/src/cli/index.ts to see how I fix it in the benchmarks.
Out of curiousity: Are you using box2d in node.js other than for benchmarking?
I'm using box2d server-side as part of my authoritative game server architecture. Clients run box2d locally in their browser and send their inputs to the nodejs server. The server is also running box2d in a worker thread, which computes the results of received inputs, then sends the updated world state back to each client.
same problem when i use node v14.x. solve this problem with node v16.x.
This seems to be originating from the
b2Timer
class and its usage ofperformance.now()
when@box2d/core
is executed from nodejs. A simple fix would be to synchronously require the performance module when running innode>=8.5
.However, this leads to
Module "perf_hooks" not found
error when bundling with webpack, unless{externals: {perf_hooks: 'empty'}}
is set in the config.