Skip to content

docs: update Hit Test tutorial to use getInputSourceState instead of deprecated useXRHandState#454

Open
micronic85 wants to merge 2 commits into
pmndrs:mainfrom
micronic85:fix/Hit_Test_document
Open

docs: update Hit Test tutorial to use getInputSourceState instead of deprecated useXRHandState#454
micronic85 wants to merge 2 commits into
pmndrs:mainfrom
micronic85:fix/Hit_Test_document

Conversation

@micronic85

Copy link
Copy Markdown

This PR updates the Hit Test tutorial (hit-test.md) to replace the deprecated useXRHandState hook with the current getInputSourceState approach from @react-three/xr.

Changes:

  • Replaced all references to useXRHandState with getInputSourceState
  • Adjusted related explanation text and code samples
  • Ensured consistency with current API usage

Let me know if any further tweaks are needed!

@bbohlender

Copy link
Copy Markdown
Collaborator

Thanks for the PR!

The correct hook in this case is "useXRInputSourceStateContext()", so the developer does not have to provide information about the input source type and its handedness because its provided through the context :)

@micronic85

Copy link
Copy Markdown
Author

Thanks for the clarification, @bbohlender!

That makes sense. Using useXRInputSourceStateContext() is indeed a better approach as it automatically retrieves the type and handedness from the context, simplifying the API for the user.

I've updated the PR to replace xr.getInputSourceState("hand", "right") with useXRInputSourceStateContext() as suggested.

const store = createXRStore({
  hand: {
    right: () => {
      const state = useXRInputSourceStateContext();
      // ...
    }
  }
});

This makes it clearer how the state retrieved from the context is then used within the hand configuration function.

@bbohlender

Copy link
Copy Markdown
Collaborator

@micronic85 I don't see the update you mentioned beeing applied to the files :)

@micronic85

Copy link
Copy Markdown
Author

@bbohlender, I've updated the code

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 this pull request may close these issues.

2 participants