how to use jit.anim.drive and jit.anim.node in javascript
Could someone please provide a snippet to show me how to use jit.anim.drive 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 jit.gl.gridshape 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 jit.anim.drive 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.
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 jit.anim.drive outside of javascript, and create an "anything" function to pass messages from the max-box jit.anim.drive, 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 anim.drive (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.
This looks great, thanks!!!
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?
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.