Gamebop / physics

Physics components for PlayCanvas
https://gamebop.github.io/docs/
3 stars 1 forks source link

Mutable compound shape #88

Closed LeXXik closed 1 month ago

LeXXik commented 1 month ago

PR adds support for a mutable compound shape. In contrast with the static compound shape, this shape allows to add/remove/modify its children shapes after creation.

entity.addComponent('body', {
    shape: SHAPE_MUTABLE_COMPOUND
});

// can add new shapes to it
const shapeIndex = app.physics.createShape({ shape: SHAPE_SPHERE });
entity.body.addShape(shapeIndex, localPosition, localRotation);

// remove a child shape
entity.body.removeShape(childIndex);

// modify a child shape
entity.body.modifyShape(childIndex, localPosition, localRotation);