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

Webxr cpu #29059

Draft
wants to merge 3 commits into
base: dev
Choose a base branch
from
Draft

Webxr cpu #29059

wants to merge 3 commits into from

Conversation

MichaelLangbein
Copy link

@MichaelLangbein MichaelLangbein commented Aug 4, 2024

It seems that, as for now, threejs doesn't support cpu-optimized WebXR depth-sensing.

I'm using an older device (a Pixel 3) and found that a lot of the WebXR examples don't work on this phone.
I think there are two issues with supporting this device (and probably a few other order devices, too), but please do correct my if I've misunderstood anything:

  1. Currently, threejs only instantiates glBinding = new XRWebGLBinding if session.renderState.layers exists, that is, if the WebXR-layers module is being supported (code here).
  2. My device can only handle cpu-optimized depth sensing; but currently threejs seems to only use the gpu-optimized access method (code here, cpu-style access method described here)

So I've been playing around with this a little bit - I hope that this PR can serve as a basis for discussion.

I guess we'd have to figure out a few questions, though:

  1. Does threejs want to support cpu-optimized depth-sensing?
  2. If so, one reasonable way to go about this would be to create a cpu-equivalent of the current WebXRDepthSensing class - this PR creates a WebXRDepthSensingCpu class.
  3. Since the cpu based depth-data is not provided as a WebGL texture but as an array on the cpu, I don't think one could mirror the WebXRDepthSensing API surface perfectly: for example, we could create a WebGL texture from the cpu-array to mirror the getDepthTexture method, but that would involve a lot of copying of data from cpu to gpu.
  4. So in the most general form: what should a possible WebXRDepthSensingCpu look like?

With or without cpu-optimized depth-sensing, threejs has pretty nice WebXR support - thanks btw for all those examples! For now I've refrained from creating a concrete example for cpu-based depth-sensing, just because I guess that from this discussion some significant changes might still come about.

Cheers!

@MichaelLangbein MichaelLangbein marked this pull request as draft August 4, 2024 09:02
Copy link

github-actions bot commented Aug 4, 2024

📦 Bundle size

Full ESM build, minified and gzipped.

Filesize dev Filesize PR Diff
684 kB (169.4 kB) 684.7 kB (169.6 kB) +650 B

🌳 Bundle size after tree-shaking

Minimal build including a renderer, camera, empty scene, and dependencies.

Filesize dev Filesize PR Diff
460.9 kB (111.2 kB) 461.5 kB (111.4 kB) +650 B

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.

1 participant