我正在使用 p5.js 和 Kinectron 让一台服务器计算机通过 LAN 显示来自另一台计算机的 RGB、深度和骨架数据,它是自己的 kinect。
使用 p5.js,我试图将两个不同的变量记录到控制台,但我只能记录其中一个变量。
代码:
...
function drawJoint(joint) {
fill(100);
console.log( "kinect1" + joint);
// Kinect location data needs to be normalized to canvas size
ellipse( ( joint.depthX * 300 ) + 400 , joint.depthY * 300 , 15, 15);
fill(200);
...
function draw2Joint(joint2) {
fill(100);
console.log ("kinect2" + joint2);
// Kinect location data needs to be normalized to canvas size
ellipse(joint2.depthX * 300 , joint2.depthY * 300, 15, 15);
fill(200);
...
运行上述代码时,控制台仅实时显示来自 Kinect 1 的关节数据,而我需要将两个 Kinect 的关节数据都记录到控制台。
如何将 console.log 用于多个变量/参数?
提前致谢!
原文由 Jay Tailor 发布,翻译遵循 CC BY-SA 4.0 许可协议
您将不得不使用全局变量,以便可以同时记录它们。以下是要添加到您目前拥有的功能中的代码行。