XRLightProbe: reflectionchange イベント

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

Experimental: これは実験的な機能です。
本番で使用する前にブラウザー互換性一覧表をチェックしてください。

WebXR の reflectionchange イベントは、推定反射立方体のマップが変更されるたびに発生します。これは、異なる照明条件での使用や、照明自体の直接的な変更に応じて発生します。このイベントはキャンセル不可です。

構文

このイベント名を addEventListener() などのメソッドで使用するか、イベントハンドラープロパティを設定するかしてください。

js
addEventListener("reflectionchange", (event) => {});

onreflectionchange = (event) => {};

イベント型

Event です。

reflectionchange イベントの使用

照明に関する reflectionchange イベントが発生するたびに、XRWebGLBinding.getReflectionCubeMap() を呼び出すことで、更新された立方体マップを取得することができます。この方法は、 XRFrame ごとに照明情報を取得するよりもコストがかかりません。

js
const glBinding = new XRWebGLBinding(xrSession, gl);
const lightProbe = await xrSession.requestLightProbe();
let glCubeMap = glBinding.getReflectionCubeMap(lightProbe);

lightProbe.addEventListener("reflectionchange", () => {
  glCubeMap = glBinding.getReflectionCubeMap(lightProbe);
});

onreflectionchange イベントハンドラープロパティ

reflectionchange イベントは onreflectionchange イベントハンドラープロパティを使用しても利用できます。

js
lightProbe.onreflectionchange = (event) => {
  glCubeMap = glBinding.getReflectionCubeMap(lightProbe);
};

仕様書

Specification
WebXR Lighting Estimation API Level 1
# eventdef-xrlightprobe-reflectionchange
WebXR Lighting Estimation API Level 1
# dom-xrlightprobe-onreflectionchange

ブラウザーの互換性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
reflectionchange event
Experimental

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support
Experimental. Expect behavior to change in the future.

関連情報