async function create3dFromSvgV8(svg, type, scaleBy) {
const loader = new THREE.SVGLoader();
let paths = loader.parse(svg.outerHTML).paths;
let style = paths[0].userData.style;
const shapes = [],
points = [];
paths.forEach((path, i) => {
paths[i].toShapes(true, false).forEach((shape, i) => {
shapes.push(shape);
});
for (let j = 0, jl = path.subPaths.length; j < jl; j++) {
points.push(path.subPaths[j].getPoints());
}
});
const group = new THREE.Group();
let h = 600;
var center = { x: width / 2, y: h / 2 };
const material = new THREE.MeshBasicMaterial({ side: THREE.DoubleSide });
const depth = 40;
if( ['geoms'].includes(type) ){
shapes.forEach(shape => {
const geometry = new THREE.ExtrudeBufferGeometry(shape, { depth: depth, bevelEnabled: false });
material.color = new THREE.Color().setStyle( 'blue' )
const mesh = new THREE.Mesh(geometry, material);
group.add(mesh);
});
}
group.rotateX(Math.PI);
group.scale.multiplyScalar(scaleBy);
center = { x: width * scaleBy, y: h * scaleBy };
group.translateX(-center.x / 2 + 0);
group.translateY(-center.y / 2 + 0);
return group;
}