gpt4 book ai didi

javascript - 如何获取 Facebook AR 手部追踪器的 x 位置?

转载 作者:行者123 更新时间:2023-11-30 14:15:32 24 4
gpt4 key购买 nike

对于手部追踪器,他们的补丁具有 X、Y 和 Z 信息,当手部被追踪时,会出现一些值。我如何通过脚本获得这些值(value)?是否可以?没有任何手部跟踪脚本示例。

到目前为止,我有以下方法来确定是否检测到一只手,但仍然不确定是否获得该位置:

//im assuming this is the correct module
const HandTracking = require('HandTracking');
const Scene = require('Scene');

//this is to check if a hand is detected
HandTracking.count.monitor().subscribe(function(e){
if(e.newValue){
Debug.log("hand found");
}
})

更新

所以我假设它有这样的东西:

var thehand = HandTracking.hand(0);
var posx = thehand.cameraTransform.x.lastValue;
Debug.log(posx);

但是这种方式被弃用了?需要使用 subscribeWithSnapshot 但我不确定如何实现它。

它还需要是动态的(?),因为值会随着每次移动而变化。

最佳答案

你在正确的轨道上,你需要的只是:

var posx = thehand.cameraTransform.x;

这将为您提供手 x 位置的信号。要调试此值,您可以使用:

Diagnostics.watch("hand x",posx);

信号是一个随时间变化的值,它可以绑定(bind)到另一个对象属性,例如:

mySceneObject.transform.x =  thehand.cameraTransform.x;

这会将手的 x 位置信号绑定(bind)到对象的 x 位置,以便对象随手移动。

在此处阅读有关信号的更多信息:https://developers.facebook.com/docs/ar-studio/scripting/reactive

它们是在 AR Studio 中编写脚本的非常强大的工具和基本知识。

希望这对您有所帮助!

关于javascript - 如何获取 Facebook AR 手部追踪器的 x 位置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53628110/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com