donmccurdy / glTF-Transform

glTF 2.0 SDK for JavaScript and TypeScript, on Web and Node.js.
https://gltf-transform.dev
MIT License
1.42k stars 150 forks source link

Support new features in Meshoptimizer v0.20 #1153

Open donmccurdy opened 1 year ago

donmccurdy commented 1 year ago

From https://github.com/zeux/meshoptimizer/releases/tag/v0.20

Related:

donmccurdy commented 8 months ago

Helpful test case for attribute-aware simplification:

https://sketchfab.com/3d-models/bananya-birbo-900ce1ec328e486296cfee70b9b13a45

donmccurdy commented 7 months ago

It looks like there are breaking changes planned for the simplifyWithAttributes API, which is still experimental:

https://github.com/zeux/meshoptimizer/pull/601

I think the rest of this task – supporting simplifyWithAttributes — will need to wait for a 4.1+ release.

kzhsw commented 4 months ago

v0.21 is released: https://github.com/zeux/meshoptimizer/releases/tag/v0.21 So when adding new features requiring new version, is there a fallback for old versions to keep them working, or sonething like a compatibility matrix for users to help them choose or update versions of 3rd party dependency?

donmccurdy commented 4 months ago

There's only one such feature today, simplifyPoints, handled by skipping point simplification if the meshopt version doesn't support it:

https://github.com/donmccurdy/glTF-Transform/blob/23e499f9b0acabc098ca7d82647d17c2e7892d22/packages/functions/src/simplify.ts#L115-L120

If compatibility becomes more complicated in the future, we could either provide a compatibility matrix or add a meshoptimizer version range to optionalDependencies.

kzhsw commented 4 months ago

Another thing to nominate is the change to useWorkers in v0.20, it can be used to avoid memory leak at the cost of being async (could be a breaking change). Also, can simplify and other meshopt-based functions run multi-threaded?

donmccurdy commented 4 months ago

We'll have to check if the workers are supported in different environments (web, Node.js, and Deno) but I think that would be a good addition, yes. glTF Transform generally does not spawn threads or workers itself (KTX compression is an exception) but dependencies certainly could.