const polygonBody = window.polygonBody;
const paper = this.view.paper; // get a copy of the PaperJS API
const vectorPoints = polygonBody.vertices;
const paperPath = new paper.Path({
segments: vectorPoints,
pivot: Matter.Vertices.centre(vectorPoints), // To center the paper Path properly
strokeColor: 'black',
fillColor: 'blue',
closed: true,
applyMatrix: false, // Store the rotation
});
const wickPath = new Wick.Path({
path: paperPath
});
// Add it to the active frame.
project.activeFrame.addPath(wickPath);
onEvent('update', function () {
wickPath.x = polygonBody.position.x;
wickPath.y = polygonBody.position.y;
wickPath.view.item.rotation = polygonBody.angle * 180/Math.PI; // Set the rotation of the paper Path
});
found out how to fix this! besides the rotation, the code also fixes a centering issue of the paperPath