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

URDFLoader's load function incorrectly caches workingPath while being used in R3F useLoader #300

Closed
smeng9 opened this issue Dec 24, 2024 · 0 comments · Fixed by #301
Closed
Milestone

Comments

@smeng9
Copy link
Contributor

smeng9 commented Dec 24, 2024

Hi @gkjohnson ,

We have a use case in R3F with this library to load multiple URDF models based on a state variable.
Basically the minimal reproducible example looks like the following

  // We have multiple buttons at the bottom and user can select the urdf to render
  const [urdfPath, setURDFPath] = useState("model1/default.urdf")

  const object = useLoader(
    URDFLoader,
    `${apiUrl}/{urdfPath}`,
  );

  // Returns a list of buttons and a scene

In the first rendering the working path will be ${apiUrl}/model1. (See how THREE.LoaderUtils.extractUrlBase extracts workingPath https://github.com/gkjohnson/urdf-loaders/blob/master/javascript/src/URDFLoader.js#L89

In subsequent render user change the model to model2/robot.urdf. However the workingPath will not be updated https://github.com/gkjohnson/urdf-loaders/blob/master/javascript/src/URDFLoader.js#L115 and it uses the wrong model1 path to load the meshes for model2.

To apply the fix remove the if condition check.

Thanks~

@gkjohnson gkjohnson added this to the v0.12.4 milestone Jan 1, 2025
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

Successfully merging a pull request may close this issue.

2 participants