[英]How do I make a heart beat with 3.JS and Leap Motion?
So I have a scene with my 3D model of a heart which I have imported from Blender. 因此,我有一个场景,其中包含我从Blender导入的心脏3D模型。
I have hooked it up with a Leap Motion so that we can move and rotate the heart model. 我已将其与Leap Motion连接起来,以便我们可以移动和旋转心脏模型。
I want to be able to make the heart grow and shrink (to simulate a beating heart) and to play a beating heart sound effect, but only when someone is interacting with the Leap. 我希望能够使心脏成长和收缩(模拟跳动的心脏)并发挥跳动的心音效果,但前提是只有有人与Leap交互时才可以。
I am new to 3.JS and have no idea where to start. 我是3.JS的新手,也不知道从哪里开始。
Can someone help? 有人可以帮忙吗?
I'm fairly new to THREE JS but was working on a similar project in the recent past. 我是THREE JS的新手,但是最近正在从事类似的项目。 To make the heart grow and shrink, I would invoke the Scale tool within the Animation loop of THREE.js : 为了使心脏成长和收缩,我将在THREE.js的Animation循环内调用Scale工具:
count = 0
function render() {
if (count < 21){
heart.scale.x += 0.01
heart.scale.y += 0.01
heart.scale.z += 0.01
count += 1
}
if ((count > 20) && (count < 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
count += 1
} else if (count == 40){ count = 0}
renderer.render( scene, camera );
}
You could also use Tween JS for a more clinical and realistic heartbeat function. 您也可以使用Tween JS获得更临床和更逼真的心跳功能。
for Sound, take a look at this example : http://threejs.org/examples/#misc_sound 对于声音,请看以下示例: http : //threejs.org/examples/#misc_sound
for setup with your LeapMotion, I would imagine that you would have a conditional that triggers the animation loop when receiving input and triggering the beating heart and sound loop. 对于用LeapMotion进行设置,我可以想象您有一个条件,当接收输入并触发跳动的心脏和声音循环时会触发动画循环。 Syncing the animation and sound loop should be straightforward. 同步动画和声音循环应该很简单。
Hope this helps. 希望这可以帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.