XRWebGLBinding: getReflectionCubeMap() 方法
XRWebGLBinding 介面的 getReflectionCubeMap() 方法返回一個包含反射立方體貼圖紋理的 WebGLTexture 物件。
紋理格式由會話的 reflectionFormat 指定。有關更多詳細資訊,請參閱 XRSession.requestLightProbe() 和 XRSession.preferredReflectionFormat 中的 options 引數。預設情況下,使用 srgba8 格式。當使用 rgba16f 格式時,您需要處於 WebGL 2.0 上下文中,或者在 WebGL 1.0 上下文中啟用 OES_texture_half_float 擴充套件。
語法
js
getReflectionCubeMap(lightProbe)
引數
lightProbe-
呼叫
XRSession.requestLightProbe()返回的XRLightProbe物件。
返回值
一個 WebGLTexture 物件。
示例
通常,當光探針上觸發 reflectionchange 事件時,您會呼叫 getReflectionCubeMap() 來檢索更新的立方體貼圖。這比為每個 XRFrame 檢索光照資訊更高效。
如果使用 rgba16f 格式,請在 WebGL 1.0 上下文中啟用 OES_texture_half_float 擴充套件。
js
const glBinding = new XRWebGLBinding(xrSession, gl);
gl.getExtension("OES_texture_half_float"); // if rgba16f is the preferredReflectionFormat
xrSession.requestLightProbe().then((lightProbe) => {
lightProbe.addEventListener("reflectionchange", () => {
glBinding.getReflectionCubeMap(lightProbe);
});
});
規範
| 規範 |
|---|
| WebXR 光照估算 API Level 1 # dom-xrwebglbinding-getreflectioncubemap |
瀏覽器相容性
載入中…