mirror of
https://github.com/exogen/t2-model-skinner.git
synced 2026-02-19 22:53:42 +00:00
17 lines
529 B
TypeScript
17 lines
529 B
TypeScript
import React, { useContext } from "react";
|
|
import { ModelViewerElement } from "@google/model-viewer";
|
|
|
|
export const ModelViewerContext = React.createContext<{
|
|
modelViewer: ModelViewerElement;
|
|
model: NonNullable<ModelViewerElement["model"]>;
|
|
isLoaded: boolean;
|
|
} | null>(null);
|
|
ModelViewerContext.displayName = "ModelViewerContext";
|
|
|
|
export default function useModelViewer() {
|
|
const context = useContext(ModelViewerContext);
|
|
if (!context) {
|
|
throw new Error("No ModelViewerContext.Provider");
|
|
}
|
|
return context;
|
|
}
|