Skip to content

Conversation

@Jordan-Lane
Copy link
Contributor

For Potree1 models we are able to provide a custom xhrRequest that is used when requesting any of the resources associated with the model. This is particularly useful when trying to add custom authentication headers to the requests.

Potree2 models are loaded with the same API, however currently the xhrRequest that is passed in is only used for loading the metadata.json file and is not used for fetching the octree.bin or hierarchy.bin files. This means that we cannot use authentication headers for loading these bin files.

This PR is to fix that, so we are able to use custom headers for Potree2 models, the same way we can for Potree1 models.

const urlOctreeCacheable = `${urlOctree}?range=${first}to${last}`;

const headers = { Range: `bytes=${first}-${last}`, 'content-type': 'multipart/byteranges' };
const response = await this.xhrRequest(urlOctreeCacheable, { headers });
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is to fix Potree2 requests not being cached by the browser. To fix this, we explicitly add the byteRange as a query param to the request, creating a unique URI, and allowing Potree2 octree requests to be cached.

I would prefer merging this change as a seperate PR, however it builds off the xhrRequest changes that were a part of this PR. Please let me know if you would prefer this as a separate PR (or if you can think of a better way to make the request cacheable) and I will make that change. Thanks!

@pjurczynski
Copy link
Collaborator

We've run prettier recently. It's highly recommended to first run "npm run format:write", commit and rebase.

@Jordan-Lane
Copy link
Contributor Author

Jordan-Lane commented Jun 25, 2025

Due to the latest changes, I will have to reimplement this PR. I'll do this, and be sure to run prettier as well

@Jordan-Lane
Copy link
Contributor Author

Closing in favour of the updated PR #206 . Which is cleaner, and is built upon the new Decoder + LoadingContext design

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.

3 participants