UNPKG

react-native-filament

Version:

A real-time physically based 3D rendering engine for React Native

32 lines (31 loc) 953 B
import { useFilamentContext } from './useFilamentContext'; import { useWorkletEffect } from './useWorkletEffect'; /** * Creates and sets the skybox for the scene depending on the options provided. * If `null` is passed, the skybox will be removed. */ export function useSkybox(options) { const { engine } = useFilamentContext(); const hasOptions = options != null; const { showSun, envIntensity } = options ?? {}; const texture = hasOptions && 'texture' in options ? options.texture : undefined; const color = hasOptions && 'color' in options ? options.color : undefined; useWorkletEffect(() => { 'worklet'; if (!hasOptions) { engine.clearSkybox(); return; } if (texture) { engine.createAndSetSkyboxByTexture(texture, showSun, envIntensity); } else if (color) { engine.createAndSetSkyboxByColor(color, showSun, envIntensity); } }); } //# sourceMappingURL=useSkybox.js.map