@threlte/xr
Version:
Tools to more easily create VR and AR experiences with Threlte
28 lines (27 loc) • 883 B
JavaScript
import { getContext, setContext } from 'svelte';
const handContextKeys = {
left: Symbol('pointer-controls-context-left'),
right: Symbol('pointer-controls-context-right')
};
const contextKey = Symbol('pointer-controls-context');
export const getHandContext = (hand) => {
return getContext(handContextKeys[hand]);
};
export const setHandContext = (hand, context) => {
setContext(handContextKeys[hand], context);
};
export const getControlsContext = () => {
return getContext(contextKey);
};
export const setControlsContext = (context) => {
setContext(contextKey, context);
};
const internalContextKey = Symbol('pointer-controls-internal-context');
export const getInternalContext = () => {
return getContext(internalContextKey);
};
export const setInternalContext = () => {
setContext(internalContextKey, {
dispatchers: new WeakMap()
});
};