UNPKG

react-native-filament

Version:

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

38 lines (36 loc) 1.1 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.useSkybox = useSkybox; var _useFilamentContext = require("./useFilamentContext"); var _useWorkletEffect = require("./useWorkletEffect"); /** * Creates and sets the skybox for the scene depending on the options provided. * If `null` is passed, the skybox will be removed. */ function useSkybox(options) { const { engine } = (0, _useFilamentContext.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; (0, _useWorkletEffect.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