svg-webgl-loader-opti
TypeScript icon, indicating that this package has built-in type declarations

2.3.1 • Public • Published

svg-webgl-loader-opti

Introduction

svg-webgl-loader-opti, a fork of svg-webgl-loader optimized for multiple renderings. All credits go to the original author, MoeYc.

Installation

npm/yarn

npm i svg-webgl-loader-opti
yarn add svg-webgl-loader-opti

Usage

import svgLoader from "svg-webgl-loader-opti";
import svgUrl from "./img/test.svg";

// load and parse svg data
const svgData = await svgLoader(svgUrl);

// load the canvas and create the buffers
loader.load({
  gl,
  shaders: {
    vertex: vertexShader,
    fragment: fragmentShader
  },
  loc: {
    width: 400,
    height: 400,
  },
  needTrim: false,
});

// draw on the buffer (can be called at every frame)
loader.draw({
  scale: 0.8,
  loc: { x: 0.5, y: 0 },
  needFill: true,
  needStroke: true,
});

Remark

svg-webgl-loader mainly refers to the scheme of rendering svg in three.js: parse the paths, discrete paths to points and triangulate, then the svg would be analyzed to many triangles, so that it can be rendered by the webgl shader.

Readme

Keywords

none

Package Sidebar

Install

npm i svg-webgl-loader-opti

Weekly Downloads

1

Version

2.3.1

License

MIT

Unpacked Size

409 kB

Total Files

72

Last publish

Collaborators

  • th0rgal