Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static toGeometry({ svg, id }: SetupFromSvgParams) {
- svg.setAttribute('xmlns', 'http://www.w3.org/2000/svg');
- // svg.removeAttribute('width');
- // svg.removeAttribute('height');
- svg.removeAttribute('fill');
- svg.removeAttribute('aria-hidden');
- svg.removeAttribute('data-icon-path');
- svg.removeAttribute('class');
- svg.removeAttribute('data-js-selector');
- // let svgMarkup = svg.outerHTML;
- let svgMarkup = `<svg width="28" height="28" viewBox="0 0 28 28" xmlns="http://www.w3.org/2000/svg"><path d="M27.24 23.917L15.01 2.736a1.167 1.167 0 00-2.02 0L.76 23.916c-.448.778.113 1.75 1.011 1.75h24.457c.899 0 1.46-.972 1.011-1.75zM13.416 9.333h1.166v8.75h-1.166v-8.75zM14 21.583a.875.875 0 110-1.75.875.875 0 010 1.75z"></path></svg>`;
- const loader = new SVGLoader();
- const svgData = loader.parse(svgMarkup);
- console.log('svg: ', svgMarkup);
- console.log('id: ', id);
- const svgGroup = new THREE.Group();
- svgGroup.scale.set(10, 10, 1);
- svgData.paths.forEach((path) => {
- const shapes = path.toShapes(false);
- const material = new THREE.MeshBasicMaterial({
- color: path.color,
- side: THREE.FrontSide,
- depthWrite: false,
- });
- shapes.forEach((shape) => {
- const geometry = new THREE.ShapeGeometry(shape);
- const mesh = new THREE.Mesh(geometry, material);
- svgGroup.add(mesh);
- });
- });
- svgGroup.scale.y *= -1;
- this._svgGeometries.set(id, svgGroup);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement