@autoquote3d/3d-thumbnail-renderer
v1.0.13
Published
React hook for generating 3D model thumbnails from STL and OBJ files
Maintainers
Readme
@autoquote3d/3d-thumbnail-renderer
A React hook for generating thumbnails from 3D model files (STL and OBJ).
Installation
npm install @autoquote3d/3d-thumbnail-rendererUsage
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" />;
}Props
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'
Return Values
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
License
MIT
