three.jsbuffer-geometry

How to apply SubdivisionModifier on BufferGeometry?


Can someone give me a pointer on where should start?

I am trying to port this code → http://glennchun.github.io/free-form-deformation/ to the latest threejs Version.

the major challenge I’m facing is how to divide Geometry into multiple Faces. Since SubdivisionModifier is removed from the latest threejs version what should I do how do I create a subDivision on geometry so I can attach the related face to my transform controls and deform them? Reference

SubdivisionModifier works on THREE.Geometry() and now THREE.Geometry() is not present in threeJS r-136. What I've done I started converting THREE.Geometry() Meshes to THREE.BufferGeometry() but SubdivisionModifier does not work on BufferGeometry.

So can anyone please point me to any new Library which replaced SubdivisionModifier or any new threeJS library which I can use?


Solution

  • The original subdivision modifier in three.js was based on the Catmull-Clark subdivision surface algorithm, which works best for geometry with convex coplanar n-gon faces. This modifier last appeared in release 59 (available here). To use the Catmull-Clark algorithm with the current triangle based BufferGeometry, it would be best to separate convex coplanar faces. The general idea would be go through triangles one by one, first gathering neighboring triangles with the same normals (to ensure coplanar) and then doing edge traversal to determine convex polygon faces. You would then run through the Catmull-Clark algorithm, and rebuild a new triangle based BufferGeometry.

    To simplify subdivision with triangle meshes, three.js switched to the Loop subdivision surface algorithm in r60 until it was removed in r125 (available here). This algorithm generally doesn't look as nice on some geometries as it heavily weights corners with shared vertices and the modifier was eventually removed.

    I have recently implemented a new modifier using Loop subdivision for modern three.js BufferGeometry and released it on GitHub under the MIT license. It includes a pre-subdivision pass to evenly split coplanar faces, smoothing sharp geometries more evenly.

    Here is a demo of it in action.