-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Doesn't work on latest Node #59
Comments
It appears to work with node |
I had the same problem but @Birch-san helped me here #65 Solution: init-box2d.js import Box2DLib from "box2d-wasm";
export let box2d = null;
export function initBox2D() {
return new Promise(resolve => {
Box2DLib({
locateFile: (url, scriptDirectory) => "file:///opt/render/project/src/node_modules/box2d-wasm/dist/umd/Box2D.simd.wasm"
}).then((re) => {
box2d = re;
resolve();
});
});
} app.js import { box2d, initBox2D } from "./init-box2d.js";
async function init() {
await initBox2D();
const {
b2Vec2,
b2World
} = box2d;
const gravity = new b2Vec2(0, -3);
const world = new b2World(gravity);
const g = world.GetGravity();
console.log("gravity = ", g);
}
init(); |
Looks good - I'll have to try it out! 😊 |
Small update for localhost: import Box2DLib from "box2d-wasm";
export let box2d = null;
export function initBox2D(localhost = true) {
return new Promise(resolve => {
Box2DLib({
locateFile: (url, scriptDirectory) => {
if (url.endsWith(".wasm") && !localhost) {
return "file:///opt/render/project/src/node_modules/box2d-wasm/dist/umd/Box2D.simd.wasm";
}
return scriptDirectory + url;
}
}).then((re) => {
box2d = re;
resolve();
});
});
} |
But my example is for deploying on Render.com hosting. You should change the path above to yours. I hope it will help. |
alright, ill add this to my fork |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
it works with
v14.8.0
withnvm
, but withv18.5.0
orv19
(haven't tried others) it spits this out:The text was updated successfully, but these errors were encountered: