Javascript structure syntax

usefuldesign.au's picture

I wanted to write a very simple JS to make nested structures of x,y,z rotational values for the 3d transform patch.

I searched a bunch of .qtz and JS sites for the correct syntax and could not find it – ended up coding it in XML and using XML downloader patch.

I'd still like to know how to declare a structure in a structure in JS. It was just a data port. He's the XML:

<?xml version="1.0" encoding="UTF-8"?>
<root>
   <name>Rotational Positions</name>
   <items>
      <item>
         <position>0</position>
         <Xrot>45</Xrot>
         <Yrot>45</Yrot>
         <Zrot>45</Zrot>
      </item>
      <item>
         <position>1</position>
         <Xrot>134</Xrot>
         <Yrot>720</Yrot>
         <Zrot>-45</Zrot>
      </item>
      <item>
         <position>2</position>
         <Xrot>15</Xrot>
         <Yrot>30</Yrot>
         <Zrot>15</Zrot>
      </item>
      <item>
         <position>3</position>
         <Xrot>415</Xrot>
         <Yrot>-115</Yrot>
         <Zrot>225</Zrot>
      </item>
   </items>
</root>

If somebody could give the essential JS lines I would be most grateful. Keys (xRot, yRot, zRot ) would be nice but not necessary :).

Here is my lame JS – a combination of attempts after many trials and revisions, just to give idea of where I was coming from (or not :/) .

function (__structure outputNumber) main (inputNumber)
{
   var result = new Object();
//   result[0] =  rotCoords(720,180,45);
   result[1] = [720,0,45];
/*   result[2] = (135,45,0);
   result[3] = (415,135,-45);
   result[4] = (90,180,135);
   result[5] = (30,60,30);
*/   
   return result;
}
 
function rotCoords (Xrot,Yrot,Zrot)
{
   var result = new Array(Xrot, Yrot, Zrot);
   return result;
}

Sorry for the lame question but it's giving me grief that I can't do this simplest of things with JS.