当在框架上检测到我的声音时,如何让 3D 模型头像说话
How to make the 3D model avatar talking when my voice is detected on a-frame
我想要的是在a-frame上,当我说话的时候,我的3D模型头像也在说话。
按照本指南,https://aframe.io/docs/1.1.0/introduction/models.html#animating-models, I created 3D model avatar with this resource, https://sketchfab.com/3d-models/bake-talking3-e715ab67be934a108d0a952d90c07210
但是这个gltf 3D模型一直在说话。我每次说话都需要交互式3D模型。
假设我的语音检测已经实现。
有人能回答这个问题吗?
animation-mixer
组件有两个方法应该有帮助
- playAction() 将播放
- stopAction() 将停止
Let's assume my voice detection is already implemented.
那么您的代码可能如下所示:
const modelEntity = document.querySelector("[gltf-model]")
const animationComponent = modelEntity.components["animation-mixer"]
mySpeechRecognition.onspeechstart = function() {
animationComponent.playAction();
}
mySpeechRecognition.onspeechend= function() {
animationComponent.stopAction();
}
类似于我在 this glitch 中所做的事情。绿色播放,红色停止。点开鱼查看出处
我想要的是在a-frame上,当我说话的时候,我的3D模型头像也在说话。
按照本指南,https://aframe.io/docs/1.1.0/introduction/models.html#animating-models, I created 3D model avatar with this resource, https://sketchfab.com/3d-models/bake-talking3-e715ab67be934a108d0a952d90c07210
但是这个gltf 3D模型一直在说话。我每次说话都需要交互式3D模型。
假设我的语音检测已经实现。
有人能回答这个问题吗?
animation-mixer
组件有两个方法应该有帮助
- playAction() 将播放
- stopAction() 将停止
Let's assume my voice detection is already implemented.
那么您的代码可能如下所示:
const modelEntity = document.querySelector("[gltf-model]")
const animationComponent = modelEntity.components["animation-mixer"]
mySpeechRecognition.onspeechstart = function() {
animationComponent.playAction();
}
mySpeechRecognition.onspeechend= function() {
animationComponent.stopAction();
}
类似于我在 this glitch 中所做的事情。绿色播放,红色停止。点开鱼查看出处