UNPKG

@threlte/extras

Version:

Utilities, abstractions and plugins for your Threlte apps

26 lines (25 loc) 1.01 kB
import { useThrelteUserContext } from '@threlte/core'; import { writable } from 'svelte/store'; /** * ### `useControlsContext` * * Internal registry of the controls instances mounted within the current * `<Canvas>`. Each controls component (`<OrbitControls>`, * `<TrackballControls>`, `<CameraControls>`, `<TransformControls>`) registers * itself here on mount and clears its entry on unmount. * * It powers two things: * - `<TransformControls>` reads the camera controls to enable/disable them * while a transform gizmo is being dragged. * - The public `useCameraControls`, `useOrbitControls`, `useTrackballControls` * and `useTransformControls` hooks expose the registered instance to user * code. */ export const useControlsContext = () => { return useThrelteUserContext('threlte-controls', { orbitControls: writable(undefined), trackballControls: writable(undefined), cameraControls: writable(undefined), transformControls: writable(undefined) }); };