Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function toDecimal(input, decimals){
- var res = parseFloat(Math.round(input * 100) / 100).toFixed(decimals);
- //node.warn(res);
- return res;
- }
- var obj = msg.payload;
- //node.warn(obj);
- var user = obj.user;
- //node.warn(user);
- var size = user.length;
- //node.warn(size);
- var numDecimals = this.context.global.get("numDecimals");
- if (user) {
- for (var i = 0; i < size; i++)
- {
- var bodypart = context.global.get("bodyPartSelect");
- //node.warn(bodypart);
- var body = user[i].bodyParts;
- //node.warn(body);
- var item = null;
- if(body){
- body.forEach(
- function(p){
- if(p.name == bodypart) {
- p.positions[0].x = toDecimal(p.positions[0].x, numDecimals);
- p.positions[0].y = toDecimal(p.positions[0].y, numDecimals);
- p.positions[0].z = toDecimal(p.positions[0].z, numDecimals);
- item = p;
- item.userId = i+1;
- // node.warn(item);
- node.send(item);
- return null;
- }
- }
- );
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement