Skip to content
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

Running as node.js server #16

Open
EibrielInv opened this issue May 20, 2022 · 4 comments
Open

Running as node.js server #16

EibrielInv opened this issue May 20, 2022 · 4 comments

Comments

@EibrielInv
Copy link

EibrielInv commented May 20, 2022

Hi!

I'm looking to run the library on Node for the server of a game, but I'm running with issues: self or document not defined on lines 189 and 191

I'm not able to set the correct combination of ENVIRONMENT variables :

// Determine the runtime environment we are in. You can customize this by
// setting the ENVIRONMENT setting at compile time (see settings.js).

var ENVIRONMENT_IS_WEB = false;
var ENVIRONMENT_IS_WORKER = false;
var ENVIRONMENT_IS_NODE = true;
var ENVIRONMENT_IS_SHELL = false;

What should I do to run the library on a Node script, in the command line?

@EibrielInv EibrielInv changed the title Running in node.js server Running as node.js server May 20, 2022
@fabmax
Copy link
Owner

fabmax commented May 20, 2022

I think you have to recompile the library to use it with Node. It should be enough to follow the Build Instructions and change the emscripten environment mode to node before executing the generate and build steps.

To change the environment mode you have to edit the cmake script PhysX/physx/source/compiler/cmake/emscripten/PhysXWebBindings.cmake. In line 49 the ENVIRONMENT is set. I assume you have to change web to node here. I never tried this though.

@EibrielInv
Copy link
Author

Thanks, will give it a try

@JohnnyStreet
Copy link

JohnnyStreet commented Jan 10, 2023

Can anyone please provide any updated info on this subject? I just set up a linux VM for the sole purposes of trying these steps. I was able to build with docker but I get Error: environment detection error at runtime.

@regnaio
Copy link

regnaio commented Aug 18, 2024

Thank you for the pointer, @fabmax

@JohnnyStreet I made the change in the file:

./physx-js-webidl/PhysX/physx/source/compiler/cmake/emscripten/PhysXWasmBindings.cmake:

# Replace
-s ENVIRONMENT=web,worker

# with
-s ENVIRONMENT=node,worker

This appears to work in Node

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants