Hi, I’m having a little play with xr features and to get rid of the little red squiggles I had to modify the type with an as
which feels a little gross to me.
Is this the best way to add to the IWebXRFeature type or is there some auto-magical way I’m missing?
I would probably have expected it to either have worked out the type for me or allowed me to add it in manually like this
const le = xrHelper.baseExperience.featuresManager.enableFeature<{ directionalLight: IShadowLight }>(
'xr-light-estimation',
'latest',
{
setSceneEnvironmentTexture: true,
createDirectionalLightSource: true,
},
);
Just thought I’d check if I’d missed something 
Ya, the expectation for TypeScript with WebXR features is to cast with angle brackets <WebXRLightEstimation>
or as WebXRLightEstimation
. For example:
const le = <WebXRLightEstimation>xrHelper.baseExperience.featuresManager.enableFeature(WebXRFeatureName.LIGHT_ESTIMATION, 'latest', {
setSceneEnvironmentTexture: true,
createDirectionalLightSource: true
});
or …
const le = xrHelper.baseExperience.featuresManager.enableFeature(WebXRFeatureName.LIGHT_ESTIMATION, 'latest', {
setSceneEnvironmentTexture: true,
createDirectionalLightSource: true
}) as WebXRLightEstimation;
The full list of feature classes is in the WebXRAbstractFeature
docs here:
https://doc.babylonjs.com/typedoc/classes/BABYLON.WebXRAbstractFeature
1 Like