THREE.JS / FOUNDATIONS 165

The texture has a life cycle.

Follow the lower-level WebXR Layers upload path: source canvas, texture update, binding sub-image, and GPU upload. Desktop emulation exercises the WebGL calls; a real XR session is the only place where an XR layer owns the destination texture.

Initializing Preparing WebGL2

Preparing a source canvas, CanvasTexture preview, raw texSubImage2D mirror, and guarded XR layer path...

session
-
layers
-
native
-
source frames
-
raw uploads
-
native uploads
-
readbacks
-
draw calls
-
Upload harnessdesktop emulation

The raw WebGL lane mirrors the official `bindTexture` → `texSubImage2D` sequence. It is a desktop diagnostic texture, not a native XR layer.

Upload contractdesktop path
source canvas256 × 256 RGBA
Three.js previewCanvasTexture
raw WebGL texturepending
last readbacknot run

A physical session adds `XRWebGLBinding.getSubImage(layer, frame)` and replaces the raw texture destination with the returned layer color texture.

Real session entry pointprobing

The official helper requests immersive-vr with local-floor and layers. The guarded native path is inactive unless the browser supplies all session-owned objects.

Session-only surfaceprobing
WebXR API-
immersive VR support-
renderer.xr.enabled-
XRWebGLBinding-
XRFrame-
enabled features-

Outside XR, binding, frame, and native layer destination are unavailable by design; the desktop mirror still exercises texture upload and readback.

This route intentionally stays on WebGL2. It teaches the source/update/destination boundary without claiming that a desktop raw texture is an XR layer.

THREE.JS FOUNDATIONS LAB