Using JS and GEN for 3D Math for Jitter visuals

Aug 13, 2012 at 12:41am

Using JS and GEN for 3D Math for Jitter visuals

Is it possible (and practical and efficient) to use GEN to do 3D Math (transformations) and call it via Javascript?

Currently, I’m using the sylvester javascript library to serve this function. (see – I include it by copying it to the jsextensions folder.

And it works great, except that once I begin doing many transformations using many instances generated by, things slow down and the 3d transforms are the reason for the slowdown (as far as I can tell).

Here’s just a sample of how I am using the Sylvester library.

this is a truncated js snippet:

var rightVector = codeObj.rightVector.multiply(-20.*Math.sin((p + 1) * time / 1000));
var downVector = codeObj.downVector.multiply(-30.*Math.sin((p + 1) * time / 1000));
var forwardVector = codeObj.forwardVector.multiply(-90.+codeObj.forwardAccumulation);

var resultVector=rightVector.add(downVector.add(forwardVector));

myglobal.primitivePositionMatrix.setcell(myglobal.primitiveCount, “val”, resultVector.elements[0],resultVector.elements[1],resultVector.elements[2]);

Could someone show me how I would be able to use a GEN object to serve my purposes and call it via javascript? I assume that I would have to pass a message from the js script and receive a message back from GEN? Or is there another way?

If I’m not being clear, please let me know.



Aug 13, 2012 at 4:48pm

Here’s how to use gen with JS. You have to create a .genjit file and load it via the @gen attribute in JS.

Aug 13, 2012 at 7:22pm


@Wesley can you post an example for get/set param from gen inside JS.

Like :
A [jit.gen] file composed with [param a 0. 1. 2.] in a .genjit file ….& want to pass value to [param a]

I tried somethings like :

var gen = new JitterObject(“jit.gen”)
gen.gen = “coords”;
gen.param = “2 2 2″; and another things but without success [of course i modify the coords.genjit file].

Thanks for your advise.

Aug 13, 2012 at 7:39pm

You can do:

gen.param("a", [0.5, 0, 0]);


You must be logged in to reply to this topic.