two.js icon indicating copy to clipboard operation
two.js copied to clipboard

[Enhancement] Move Two.Utils.read.XXX to Two.XXX.parse

Open jonobr1 opened this issue 3 years ago • 0 comments

Is your feature request related to a problem? Please describe. Currently the SVG interpreter relies on replicating SVG strings into elements and parsing them iteratively in a big for loop. This does not give developers the ability to parse individual elements ad hoc. Moving each read function to a static parse method on each object would allow for parsing of entire scenes as well as ad hoc parsing.

Describe the solution you'd like For all shape primitives to have a parse method that works something like this:

const path = Two.Path.parse('<path d="..." fill="red" stroke="transparent" />');
two.add(path);

Additional context This will improve code portability and make this issue more feasible.

jonobr1 avatar Jul 29 '22 23:07 jonobr1