-
-
Notifications
You must be signed in to change notification settings - Fork 35.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add volume calculator for 3d mesh #27905
Comments
what's the state of this PR? bumping for visibility and bc seems like a very useful utility |
This is an issue. The respective PR is #27906. Unfortunately, the OP has to honor the feedback in #27906 (comment) to get the code merged. As long as the code is not in the |
@Mugen87 I'm trying to use the lib but getting this error
using this import { NextResponse, type NextRequest } from "next/server";
import { Box3, Vector3 } from "three";
import { ThreeVolume } from "three-volume";
import { STLLoader } from "three/addons";
export const POST = async (req: NextRequest) => {
const body = (await req.json()) as { url: string };
if (!body.url) {
return NextResponse.json({ error: "No url provided" }, { status: 400 });
}
const t1 = performance.now();
const fileFetch = await fetch(body.url);
const arrayBuffer = await fileFetch.arrayBuffer();
const stlLoader = new STLLoader();
const fileV3 = stlLoader.parse(arrayBuffer);
const box = new Box3().setFromArray(fileV3.getAttribute("position").array);
const size = new Vector3();
const computedVolume = ThreeVolume(fileV3);
const t2 = performance.now();
return NextResponse.json(
{ help: true, dimensions: box.getSize(size), computedVolume, took: t2 - t1 },
{ status: 200 },
);
}; does someone has any solution? |
Do you mind reporting this issue at https://github.com/isalgadof/Three-volume instead? |
Description
Three has no native method to calculate mesh's volumes.
Solution
Add a method (mesh.volume) to retrieve the calculated volume of the object-mesh.
Alternatives
Pass through a method using an import for 'three-volume' package
Additional context
https://www.npmjs.com/package/three-volume
The text was updated successfully, but these errors were encountered: