Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
224 views
in Technique[技术] by (71.8m points)

Convert SVG group into a 3D shape | adding thickness with Three.js

Is there a way to convert an SVG group of paths into its 3D counterpart? In a way, It's like adding thickness to it.

I used SVGLoader to import my svg path into THREE.JS library:

loader.load(
    './test.svg',
    function ( data ) {

        const paths = data.paths;
    

        for ( let i = 0; i < paths.length; i ++ ) {

            const path = paths[ i ];

            const material = new THREE.MeshBasicMaterial( {
                color: 0x337ab7,
                side: THREE.DoubleSide,
                depthWrite: false,
                opacity: 1,
                transparent: true
            } );

            const shapes = path.toShapes( true );

            for ( let j = 0; j < shapes.length; j ++ ) {

                const shape = shapes[ j ];
                const geometry = new THREE.ShapeBufferGeometry( shape );
                const mesh = new THREE.Mesh( geometry, material );
                group.add( mesh );

            }

        }...

The SVG upload works fine. Do you know any library or trickery to accomplish this 3D transformation?

enter image description here

question from:https://stackoverflow.com/questions/65870512/convert-svg-group-into-a-3d-shape-adding-thickness-with-three-js

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Instead of creating ShapeBufferGeometry try it with ExtrudeBufferGeometry. It should be exactly what you are looking for.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...