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

relative paths for phy init not respected. #35

Open
ubernaut opened this issue Jul 16, 2024 · 1 comment
Open

relative paths for phy init not respected. #35

ubernaut opened this issue Jul 16, 2024 · 1 comment

Comments

@ubernaut
Copy link

ubernaut commented Jul 16, 2024

I ran into this problem when trying to deploy to github pages, which puts everything in a subdirectory with the name of your project ie:

https://ubernaut.github.io/simple-template/

you should be able to pass in a relative path (like './') so compact would be resolved at:

https://ubernaut.github.io/simple-template/compact

instead, it will insist on trying to find it here:

https://ubernaut.github.io/compact/

this doesn't work, phy will fail to find the physics hex files in compact if they aren't at the root of your url's path:

phy.init({
    type: "physx",
    worker: true,
    compact: true,
    scene: scene,
    renderer: renderer,
    callback: physicsReady,
    path: './'
    
  });

workaround:
You can pass in an explicit path and it does correctly prefix the dependencies so set an env variable in your package script for the path you want to use. like this (start is for local dev where it can run at root, and build is for gh pages):


  "scripts": {
    "test": "",
    "start": "export stpath='./'; parcel --https index.html",
    "build": "export stpath='/simple-template/'; parcel build index.html --public-url /simple-template/"
  },

then reference the variable in the init

  phy.init({
    type: "physx",
    worker: true,
    compact: true,
    scene: scene,
    renderer: renderer,
    callback: physicsReady,
    path: process.env.stpath
  });
@lo-th
Copy link
Owner

lo-th commented Jul 17, 2024

ok i will look that thank's
for the moment copy compact folder to public
if you use vite

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

2 participants