Parametric variables

yanomano's picture

Parametric surface is just an awesome patch :) How do you set variables ? Can you provide a structure exemple ?

THX

cwright's picture
sample JS

var result = new Object();
result.vars = new Object();
function (__structure vars) main (__number a, __number b)
{
   result.vars.a = a;   
   result.vars.b = b;
   return result;
}

The result.vars._____ part is the variable name passed on (so result.vars.yanomano would set a variable called "yanomano")

gtoledo3's picture
This may be of use for

This may be of use for ideas...

PreviewAttachmentSize
changing expressions.qtz5.76 KB

yanomano's picture
Kineme rocks

Thanks Chris ;)

kristopf's picture
Off topic

Off topic question: Any reason you're declaring result as a global variable instead of in the scope of the main function? Is there a performance gain not creating a new Object() every frame, or is it just your convention?

cwright's picture
less is more, more or less

When optimizing, the most fundamental axiom is "do as little as possible" -- this goes for code, compositions, etc. One simple way to do so is to pull redundant stuff out of places that are executed repeatedly (like the main function).

JS, as an interpreted language (I'm pretty sure it's interpreted in QC -- in browsers and other places, they have hot-shot JIT compilers now, which should be rather snappy) benefits a lot from doing as little as possible. So I generally opt to have result get allocated exactly once, and then never deal with allocation again (allocation can be a bit expensive, and JS's garbage collector in QC sucks, so I try to avoid needing it as much as possible).

I'd guess that the performance gain is negligible in this case, but it's a habit I like to be in.

pixelnoizz's picture
kineme named struct. maker

for me working with structure maker, in that case the input keys names are the variables names. Maybe more simple then JS. Or not?:)

yanomano's picture
The geometry of Sea Shells

The Geometry of Sea Shells...procedural 3D modeling explain...;)

gtoledo3's picture
Hahah, I was actually

Hahah, I was actually breaking out notes I took in highschool and college (yes, I keep notes from that long ago.... I'm a sick, sick man....).