Type script code into the script window to try out the X3DOM field interface.
You can use the pre-defined objects for the getAttribute, setAttribute, getField and setField methods.
For the requestFieldRef and returnFieldRef methods, you can define your own variable to hold the reference and operate on it.
You can, for example, try this and see what happens to Suzanne:
var colorFieldObj = colorNode.requestFieldRef("color");
for (var i = 650; i < 730; ++i)
{
colorFieldObj[i].r = 1.0;
colorFieldObj[i].g = 0.0;
colorFieldObj[i].b = 0.0;
}
colorNode.releaseFieldRef("color");
The equivalent code for getFieldValue and setFieldValue looks like this:
var colorArray = colorNode.getFieldValue("color");
for (var i = 650; i < 730; ++i)
{
colorArray[i].r = 1.0;
colorArray[i].g = 0.0;
colorArray[i].b = 0.0;
}
colorNode.setFieldValue("color", colorArray);
Note, however, that getFieldValue and setFieldValue create copies of the fields and
therefore are significantly slower for large amounts of data.
Available Variables:
Name
Type
Meaning
colorNode
Color
Color DOM node, using a "color" field for vertex colors
colors1_str
String
Attribute string, containing values of color testset 1
colors2_str
String
Attribute string, containing values of color testset 2
colors1_obj
MFColorRGBA
Field object, containing values of color testset 1
colors2_obj
MFColorRGBA
Field object, containing values of color testset 2