react-native-filament
Version:
A real-time physically based 3D rendering engine for React Native
18 lines (17 loc) • 600 B
JavaScript
import { FilamentProxy } from '../native/FilamentProxy';
import { useWorklet } from 'react-native-worklets-core';
import { useDisposableResource } from './useDisposableResource';
export function useEngine({
backend,
config,
context
}) {
// Important: create the engine on the worklet thread, so its owned by the worklet thread
const createEngine = useWorklet(context, () => {
'worklet';
return FilamentProxy.createEngine(backend ?? undefined, config ?? undefined);
});
const engine = useDisposableResource(createEngine);
return engine;
}
//# sourceMappingURL=useEngine.js.map