how to use and jit.anim.node in javascript

    Jun 13 2012 | 5:19 am
    Could someone please provide a snippet to show me how to use and jit.anim.node in javascript?
    I would like to learn how to do 2 things.
    1. I would like to be able to make 3D transforms to a number of objects (generated in JS) using jit.anim.node as a parent to all of them. So that I can rotate all of the gridshapes together. How do I bind jit.anim.node to a number of generated gridshapes in JS?
    2. I would like to know how to implement in javascript to control a single gridshape as well as how to drive a jit.anim.node.
    Essentially, I want to know how to do what's being done in the Max help examples but in JS.

    • Jun 13 2012 | 7:58 pm
      hello. thanks for the questions.
      there is currently some limitations to using the animation objects inside of javascript. these should all be gone in a future update.
      for now, your best bet is to leave the outside of javascript, and create an "anything" function to pass messages from the max-box, to the javascript jit.anim.node. (this technique is found in the javascript example patch here: Max6/examples/jitter-examples/javascript/other/jitternotify.js)
      to set up an anim.node hierarchy inside of javascript, you can create an array of gl objects and an array of anim.node objects, and set the "anim" attribute of the gl object to the "name" attribute of the anim.node. you then can create a parent anim.node object, and set the "anim" attribute of the child anim.node objects to the "name" attribute of the parent.
      you can then pass messages from the (or any kind of message) to this parent anim.node.
      here's a basic patch with javascript to demonstrate. please let me know if anything is unclear.
    • Jun 13 2012 | 8:38 pm
      This looks great, thanks!!!
    • Jun 20 2012 | 3:04 am
      Hi Robert.
      Thanks for your help.
      I'm working my way toward getting that all working.
      I've run into a problem where my shader/texture is glitching out when I actually attach all of by generated jit.anim.nodes to a parent jit.anim.node. (like in your example).
      Please try unzipping the attached file and run the patcher. It is basically a text editor (in progress).
      When you type, you should see text in the window. You will notice that the last letter of the text will pop up whenever you type (glitchy). This only happens the first time each gridshape is drawn. If you backspace and retype, it won't happen again until you get to the new characters.
      Open up render_screen.js and comment out lines 85 and 94 and save.
      Now you will see that things are working fine, but of course the jit.anim.nodes have been disabled (by breaking the script). Basically, what I want is to be able to use the jit.anim.nodes in the way you described if you patch and the way it is kind of working here, except without the glitch. I've tried a number of things, but I don't know why I'm getting this glitch.
      Can someone shed some light on this?
    • Jun 20 2012 | 8:16 pm
      the problem, i think, is that you are using non-automatic mode rendering. this requires you to be very careful and explicit about the order you update nodes.
      is there any way you can instead of using non-automatic, use the ob3d @enable attribute to turn rendering on and off?
      i'm not entirely sure that would fix the problem, but that's the first thing i would suggest you try.