Having recently delved into THREE JS, I found myself working on a project with a similar concept not too long ago. My method for making the heart expand and contract involved utilizing the Scale tool within the Animation loop of THREE.js:
counter = 0
function animate() {
if (counter < 21){
heart.scale.x += 0.01
heart.scale.y += 0.01
heart.scale.z += 0.01
counter += 1
}
if ((counter > 20) && (counter < 40)) {
heart.scale.x = cube.scale.x - 0.01
heart.scale.y = cube.scale.x - 0.01
heart.scale.z = cube.scale.x - 0.01
counter += 1
} else if (counter == 40){ counter = 0}
renderer.render( scene, camera );
}
Another approach you could consider for achieving a smoother and more lifelike heartbeat effect is to implement Tween JS.
For incorporating sound, you may find this example useful:
When setting up your LeapMotion device, you could create a condition that activates the animation loop upon receiving input, causing the heart to beat and triggering the sound loop accordingly. Synchronizing the animation with the sound should be relatively simple.
I hope this information proves beneficial.