Remove

The remove() function lets you remove objects from the scene.

const sphereObject = sphere(32);

button("Remove sphere", () => {
    remove(sphereObject.mesh);
});

Use the spawn() function to spawn objects into the scene.