THREE.ExtrudeBufferGeometry How to Extrude According to the Given Path Point

Hello, everyone!
I’m using Extrude Buffer Geometry to stretch along a specified path. I want to stretch using my defined path point, not a fixed step. However, Figure 2 is my expected effect. What should I do? Please help me. Thank you very much.

This is my code:

        var radius = 0.12;
        var pathPoints = [
            new THREE.Vector3(0, 0, 0),
            new THREE.Vector3(0, 1.196, 0),
            new THREE.Vector3(0, 1.196, 1),
            new THREE.Vector3(0, 0, 1)
        ];
        var points = roundedCornerLine(pathPoints, radius, 12);

        var arcShape = new THREE.Shape();
        arcShape.moveTo(0, 0);
        arcShape.absarc(0, 0, radius, 0, Math.PI * 2, false);

        var path= new THREE.CatmullRomCurve3(points);
        var step = path.points.length;
        var geo = new THREE.ExtrudeBufferGeometry(arcShape, {
            extrudePath: path,
            curveSegments: 12,
            steps: step,
            bevelEnabled: false
        });
        var mesh = new THREE.Mesh(geo, new THREE.MeshPhongMaterial());
        mesh.material.wireframe = true;
        scene.add(mesh);

This is the result:
1

Figure 2 is what I expected:
2

Sorry, but ExtrudeBufferGeometry does not support such a use case. You need a custom modification for this.

Well, using ExtrudeBufferGeometry to fix steps will undoubtedly produce many useless triangles.

What you are looking for is not easy to implement in a generic way. It seems the amount of subdivision along the path should vary according to its straightness, right?

I used the roundedCornerLine method provided in previous forums to subdivide rounded corners. Everything seems perfect, but steps in Extrude Buffer Geometry limits everything. I hope the government can extend Extrude without equal time。:grin:

Hi!
Maybe these topics will be helpful: ProfiledContourGeometry, ProfiledContourGeometry MultiMaterial

You would need to implement this yourself, the default path works with fixed steps/divisions, if you override the getSpacedPoints method you can return the points with an adaptive approach / filter the points list.

1 Like