See it in action here: https://3d-thumbnail-example.vercel.app/
A React hook for generating thumbnails from 3D model files (STL and OBJ).
npm install @autoquote3d/3d-thumbnail-renderer
import { useModelThumbnail } from "@autoquote3d/3d-thumbnail-renderer";
function ModelPreview() {
const file = new File();
const { data, loading, error, progress } = useModelThumbnail({
url: URL.createObjectURL(file), // or some other valid url
fileType: "stl",
color: "#808080", // optional, defaults to gray
});
if (loading) {
return <div>Loading... {progress}%</div>;
}
if (error) {
return <div>Error: {error}</div>;
}
return <img src={data} alt="3D Model Thumbnail" />;
}
url
: URL or path to the 3D model filefileType
: Type of the 3D model file ('stl' or 'obj')color
: (Optional) Color of the model in hex format. Defaults to '#808080'
data
: Base64 encoded image data URL when completeloading
: Boolean indicating if the thumbnail is being generatederror
: Error message if something goes wrongprogress
: Number indicating the download progress percentage
MIT