hello i am trying to make a physic object from SVG.
first i try to convert vertices from svg path so it can be made into matter physic obj
i managed to do just that.
const PATH = "m 175.38095,89.958332 c -47.27637,22.676238 -96.376714,29.544658 -149.678569,0 l 2.608562,-11.879139 c 53.660637,25.584617 90.524097,18.083605 147.800047,0 z"
let pathElement = document.createElementNS('http://www.w3.org/2000/svg', 'path')
pathElement.setAttributeNS(null, 'd', PATH)
pathElement.setAttributeNS(null, 'id', 'path3780')
const setVerts = this.matter.svg.pathToVertices(pathElement, 36);
this.matter.add.fromVertices(this.scale.width * 0.5, this.scale.height * 0.2, setVerts, {isStatic: true});
now i’m trying to make the matter obj have a sprite that represents it attached to it.
i’ve exported the image to png and try to attach the vertice into the object.
const rect = this.add.sprite(this.scale.width * 0.5, this.scale.height * 0.1, GameplayAsset.test_png.key);
this.matter.add.gameObject(rect, {vertices: setVerts,})
but my exported image ends up having much larger size than the vertice that matter reads.
is there any way to synchronize matter vertice size with sprites given ?
i could possibly scale the sprite until it match matter vertice body. but it would give hard number that not that accurate.
thanks beforehand