Advertisement
Guest User

Untitled

a guest
Nov 24th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. function toDecimal(input, decimals){
  2. var res = parseFloat(Math.round(input * 100) / 100).toFixed(decimals);
  3. //node.warn(res);
  4. return res;
  5. }
  6.  
  7.  
  8. var obj = msg.payload;
  9. //node.warn(obj);
  10. var user = obj.user;
  11. //node.warn(user);
  12. var size = user.length;
  13. //node.warn(size);
  14. var numDecimals = this.context.global.get("numDecimals");
  15.  
  16. if (user) {
  17.  
  18. for (var i = 0; i < size; i++)
  19. {
  20. var bodypart = context.global.get("bodyPartSelect");
  21. //node.warn(bodypart);
  22.  
  23. var body = user[i].bodyParts;
  24. //node.warn(body);
  25. var item = null;
  26. if(body){
  27. body.forEach(
  28. function(p){
  29. if(p.name == bodypart) {
  30.  
  31. p.positions[0].x = toDecimal(p.positions[0].x, numDecimals);
  32. p.positions[0].y = toDecimal(p.positions[0].y, numDecimals);
  33. p.positions[0].z = toDecimal(p.positions[0].z, numDecimals);
  34.  
  35. item = p;
  36. item.userId = i+1;
  37. // node.warn(item);
  38. node.send(item);
  39. return null;
  40. }
  41. }
  42. );
  43. }
  44. }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement