url field of Script{} node supports inline / external javascript, and external java code
function foo(bar) {
}
if (true) {
}
var sum = a + b;
// single line
/*
multi-line
*/
SFBool) : true, false, TRUE, FALSE
SFInt32, SFTime, SFFloat) : integer or floating point numbers, stored in 64 bits (double precision)
SFVec3f, SFColor, etc..) have object representations [»]
myMultiVal[2]
myMultiVal.length
x (no typing like c's int x)
var x (keyword var helps with garbage collection & scoping, required for recursion)
=, +=, -=, *=, /=, %=
==, !=, <, <=, >, >=
+, -, *, /, % (float division of integers)
++, --
-
&, |, ^, ~, <<, >>, >>>
&&, ||, !
+
?:
SF <--> MF assignments copy value (pass by value)
if, if / else, switchif (some_boolean_condition) {
// code executes when condition is true
}
if (some_boolean_condition) {
// code executes when condition is true
} else {
// alternate code executes when condition is false
}
switch (some_variable) {
case (value_1) : // code for when some_variable = value_1
case (value_2) : // code for when some_variable = value_2
case (value_n) : // code for when some_variable = value_n
default : // code for when no conditions met
}
while, forwhile (some_boolean_condition_remains_true) {
// some code
}
for (var i = some_initial_val; i < some_limit; i++) {
// some code
}
getCurrentFramerate(), createVrmlFromString(), etc.
PI, SQRT2, E, abs(), cos(), sin(), etc.
MAX_VALUE, NEGATIVE_INFINITY, etc.
newnew objectName ([initial_value(s)])var red = new SFColor(1, 0, 0)
functionfunction addemup(aVal, bVal) {
return aVal + bVal;
}
var sum = addemup(5, 3);
eventIn: incoming value and timestamp are passed to function of same name
eventOut: assigning to an eventOut posts the value via routing (to any connected eventIns)
field: static value storage
exposedFields! (browser implementation issues)
directOutput
true to post to eventIns without routing (reading always ok)
false (scene can be optimized for things that can't change)
mustEvaluate
true for createVrmlFromX
false when ok to queue events until script result needed (better performance)
initialize() : called before world is rendered and before any events fired
shutDown() : called just prior to deleting script node from scene graph or unloading world
eventsProcessed() : called less frequently than per every event
print() : good for debugging; writes to console [»]
[-m,n] -> [0,x], or [-y,x][0,n+m][0,1] (divide by n+m)[0,x][-y,x]
[0,1] -> [1,0]
[-1,1] -> [0,1]
SFBool -> SFColor (highlighting with color change) [»]
SFVec3f -> SFColor (position -> sphere color) [»]
task06 [»]