feat(xr): WebGPU AR camera color and syncCameraColorTexture bridge#8720
Merged
Conversation
- ar-camera-color: createGraphicsDevice + AppBase; allow WebGPU - XrViews: supportedColor from active device (XRWebGLBinding vs XRGPUBinding) - XrManager: request camera-access when supportedColor without WebGL-only gate - XrBridge/Webgl/Webgpu: syncCameraColorTexture; XrView delegates; GL FBO path + comments in WebglXrBridge; WebGPU copyTextureToTexture when getCameraImage exists
Contributor
There was a problem hiding this comment.
Pull request overview
This PR extends the engine’s XR camera color pipeline to work across both WebGL and WebGPU by moving “camera image → engine texture” syncing behind the XR bridge implementations, and updates the AR camera color example to the modern createGraphicsDevice + AppBase bootstrap.
Changes:
- Adds
XrBridge.syncCameraColorTexture()and routes per-frame camera color syncing through backend bridge implementations (WebGL blit, WebGPU copy). - Requests
camera-accessfor AR whencameraColoris enabled and the runtime/device supports camera color (no longer WebGL-only). - Updates the
ar-camera-colorexample to match modern device/app initialization patterns.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/platform/graphics/xr-bridge.js | Adds a bridge-level syncCameraColorTexture entry point delegating to backend impls. |
| src/platform/graphics/webgpu/webgpu-xr-bridge.js | Implements WebGPU camera image copy path using XRGPUBinding.getCameraImage + copyTextureToTexture. |
| src/platform/graphics/webgl/webgl-xr-bridge.js | Implements WebGL camera image blit path using FBOs + blitFramebuffer (with Y-flip). |
| src/framework/xr/xr-views.js | Computes supportedColor based on active graphics backend (WebGL vs WebGPU binding availability). |
| src/framework/xr/xr-view.js | Removes inline WebGL camera blit logic and delegates to xrBridge.syncCameraColorTexture. |
| src/framework/xr/xr-manager.js | Requests camera-access whenever cameraColor is requested and views.supportedColor is true. |
| examples/src/examples/xr/ar-camera-color.example.mjs | Updates example initialization to createGraphicsDevice + AppBase. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+205
to
+212
|
|
||
| // set frame buffer to read from | ||
| device.setFramebuffer(this._cameraFbSource); | ||
| gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, src, 0); | ||
|
|
||
| // set frame buffer to write to | ||
| device.setFramebuffer(this._cameraFbDest); | ||
| gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture.impl._glTexture, 0); |
| } | ||
|
|
||
| const device = this.xrBridge.device; | ||
| const encoder = device.commandEncoder; |
Comment on lines
+64
to
+67
| if (this._cameraFbSource) { | ||
| const gl = device.gl; | ||
| gl.deleteFramebuffer(this._cameraFbSource); | ||
| this._cameraFbSource = null; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
related to #7404
Enables immersive AR camera color (
camera-access) when using a WebGPU graphics device, routes camera image sync through the XR bridge implementations, and updates the AR camera color example to the modern device bootstrap.Changes:
ar-camera-colorusescreateGraphicsDevice+AppBase(same pattern asar-basic), dropsWEBGPU_DISABLED, and keeps camera color /drawTexturebehavior.camera-accessis requested whenevercameraColoris set andviews.supportedColoris true (no longer gated on WebGL only).XrViews.supportedColor: Computed in the constructor from the active graphics device so WebGL apps only requireXRWebGLBinding, WebGPU apps onlyXRGPUBinding(plusXRCamera).XrBridge.syncCameraColorTexturedelegates toWebglXrBridge(FBO +blitFramebufferwith original comments) orWebgpuXrBridge(getCameraImage+copyTextureToTexturewhen available).XrViewonly calls the bridge each frame.Examples:
examples/src/examples/xr/ar-camera-color.example.mjs.Notes: WebGPU
getCameraImage/ texture format compatibility depends on the user agent; the WebGPU path no-ops if the API is missing. Camera color texture resize-on-XRCameradimension change is unchanged from prior behavior (still allocated once inXrView).