function rotatePoint(centerX, centerY, distance, angleInDegrees) { const angleInRadians = angleInDegrees * (Math.PI / 180); const x = centerX + (distance * Math.cos(angleInRadians)); const y = centerY + (distance * Math.sin(angleInRadians)); return { x, y, z : 0 }; } let plastic = [ 'white_plastic', 'green_plastic', 'neonblue_plastic', 'white_plastic', 'green_plastic', 'neonblue_plastic' ] let obj = [ '16mm_2in', //'16mm_2in_np', '16mm_3in', //'16mm_3in_np', '8mm_2in', //'8mm_2in_np', '8mm_3in', //'8mm_3in_np', '35mm_2in', //'35mm_2in_np', '35mm_3in'//, //'35mm_3in_np' ]; let meta = { objects : [] } let starting = 15; //(360 / (obj.length * 2)); for (let i = 0; i < obj.length; i++) { meta.objects.push ({ name : `film_core_${obj[i]}`, material : plastic[i], position : rotatePoint(0, 0, 120, starting + (i * (360 / obj.length))), rotation : { x : 0, y : 90, z : starting + (i * (360 / obj.length)) } }); } console.log(JSON.stringify(meta, null, '\t'))