<head>
</head>
<!--
<!--
Event Graph ROUTE Table
shows event connections
-->
<!--
Index for DEF nodes:
ColorRGB,
ColorRGBAholder,
ConvertColorRGBAtoRGB,
IndexedTriangleFanSetToIndexedFaceSet,
IndexedTriangleSetToIndexedFaceSet,
IndexedTriangleStripSetToIndexedFaceSet,
LineSetToIndexedLineSet,
LinkToExamples,
NodesHolderILS,
NodesHolderITFS,
NodesHolderITS,
NodesHolderTFS,
NodesHolderTS,
NodesHolderTSS,
RenderedILS,
RenderedITFS,
RenderedITS,
RenderedTFS,
RenderedTS,
RenderedTSS,
TriangleFanSetToIndexedFaceSet,
TriangleSetToIndexedFaceSet,
UnrenderedITFS,
UnrenderedITS,
UnrenderedTFS,
UnrenderedTS,
UnusedAppearance
Index for ProtoDeclare definitions:
ColorRGBA,
IndexedTriangleFanSet,
IndexedTriangleSet,
IndexedTriangleStripSet,
LineSet,
TriangleFanSet,
TriangleSet,
TriangleStripSet
-->
<Scene>
<!-- ==================== -->
<WorldInfo title='RenderingComponentPrototypes.x3d'/>
<ProtoDeclare name='ColorRGBA' appinfo='ColorRGBA defines a set of RGBA colors. Warning: VRML 97 support does not include alpha values.'
>
<ProtoInterface>
<field name='color' type='MFRotation' accessType='inputOutput'
appinfo='locally override MFColorRGBA type (which is not supported in VRML 97) in order to downgrade to Color RGB'
>
<!-- The color field is a 4-tuple float array, and so we map it to an MFOrientation for backwards compatibility with VRML 97. -->
</field>
<field name='metadata' type='SFNode' accessType='inputOutput'
appinfo='Metadata node only'
>
<!-- default initialization is NULL node to match X3D specification -->
</field>
</ProtoInterface>
<ProtoBody>
<Color DEF='ColorRGB' color='0.8 0.8 0.8'/>
<!-- remaining nodes are not rendered -->
<OrientationInterpolator DEF='ColorRGBAholder'>
<IS>
<connect nodeField='keyValue' protoField='color'/>
</IS>
</OrientationInterpolator>
<Script DEF='ConvertColorRGBAtoRGB' directOutput='true'>
<field name='colorRGBAnode' type='SFNode' accessType='initializeOnly'>
</field>
<field name='colorRGBnode' type='SFNode' accessType='initializeOnly'>
</field>
<![CDATA[
ecmascript:
function initialize ()
{
// Browser.println ('colorRGBAnode.keyValue.length=' + colorRGBAnode.keyValue.length);
for (i=0; i<=colorRGBAnode.keyValue.length-1; i++)
{
// type conversion of each array element
// specifically, colorRGBAnode.keyValue[i] is an SFRotation
// and individual element values are then extracted from that
nextColor = new SFColor (
colorRGBAnode.keyValue[i].x,
colorRGBAnode.keyValue[i].y,
colorRGBAnode.keyValue[i].z);
// note colorRGBAnode.keyValue[i].angle holds the alpha value; ignored
// Browser.println ('color[' + i + ']=' + nextColor);
colorRGBnode.color[i] = nextColor;
}
}
]]>
</Script>
<Group>
<
MetadataSet>
<IS>
<connect nodeField='metadata' protoField='metadata'/>
</IS>
</
MetadataSet>
</Group>
</ProtoBody>
</ProtoDeclare>
<!-- ==================== -->
<ProtoDeclare name='IndexedTriangleFanSet' appinfo='IndexedTriangleFanSet represents a 3D shape composed of triangles that form a fan shape around the first vertex declared in each fan.'
>
<ProtoInterface>
<field name='ccw' type='SFBool' value='true' accessType='initializeOnly'/>
<field name='colorPerVertex' type='SFBool' value='true' accessType='initializeOnly'/>
<field name='normalPerVertex' type='SFBool' value='true' accessType='initializeOnly'/>
<field name='solid' type='SFBool' value='true' accessType='initializeOnly'/>
<field name='set_index' type='MFInt32' accessType='inputOnly'
appinfo='[0 infinity] or -1'
/>
<field name='index' type='MFInt32' accessType='initializeOnly'
appinfo='[0 infinity] or -1'
>
<!-- default initialization is NULL array [] to match X3D specification -->
</field>
<field name='color' type='SFNode' accessType='inputOutput'
appinfo='Color ColorRGBA node only'
>
<!-- default initialization is NULL node to match X3D specification -->
</field>
<field name='coord' type='SFNode' accessType='inputOutput'
appinfo='Coordinate node only'
>
<!-- default initialization is NULL node to match X3D specification -->
</field>
<field name='metadata' type='SFNode' accessType='inputOutput'
appinfo='Metadata node only'
>
<!-- default initialization is NULL node to match X3D specification -->
</field>
<field name='normal' type='SFNode' accessType='inputOutput'
appinfo='Normal node only'
>
<!-- default initialization is NULL node to match X3D specification -->
</field>
<field name='texCoord' type='SFNode' accessType='inputOutput'
appinfo='TextureCoordinate node only'
>
<!-- default initialization is NULL node to match X3D specification -->
</field>
</ProtoInterface>
<ProtoBody>
<IndexedFaceSet DEF='RenderedITFS'>
<IS>
<connect nodeField='ccw' protoField='ccw'/>
<connect nodeField='normalPerVertex' protoField='normalPerVertex'/>
<connect nodeField='solid' protoField='solid'/>
<connect nodeField='color' protoField='color'/>
<connect nodeField='coord' protoField='coord'/>
<connect nodeField='normal' protoField='normal'/>
<connect nodeField='texCoord' protoField='texCoord'/>
</IS>
</IndexedFaceSet>
<Group DEF='UnrenderedITFS'>
<Shape>
<!-- is this really needed at all?? -->
<IndexedFaceSet DEF='NodesHolderITFS'>
<IS>
<connect nodeField='color' protoField='color'/>
<connect nodeField='coord' protoField='coord'/>
<connect nodeField='normal' protoField='normal'/>
<connect nodeField='texCoord' protoField='texCoord'/>
</IS>
</IndexedFaceSet>
</Shape>
<Script DEF='IndexedTriangleFanSetToIndexedFaceSet' directOutput='true'>
<field name='index' type='MFInt32' accessType='initializeOnly'/>
<field name='set_index' type='MFInt32' accessType='inputOnly'/>
<field name='renderedITFS' type='SFNode' accessType='initializeOnly'>
</field>
<field name='nodesHolder' type='SFNode' accessType='initializeOnly'>
</field>
<field name='localTraceEnabled' type='SFBool' value='true' accessType='initializeOnly'/>
<field name='coordIndexNew' type='MFInt32' accessType='initializeOnly'>
<!-- constructed during initialization -->
</field>
<IS>
<connect nodeField='index' protoField='index'/>
<connect nodeField='set_index' protoField='set_index'/>
</IS>
<![CDATA[
ecmascript:
function initialize()
{
// index is an array of triangle indices that form a fan shape
// around the first vertex declared in each fan. The ordering of
// the vertices is ccw (counter-clockwise).
// ensure terminated by -1
if (index[index.length-1] != -1) index[index.length] = -1;
// ensure legal index values
for (i=0; i <= index.length-1; i++)
{
if (index[i] < -1)
{
alwaysPrint ('error, index[' + i + ']=' + index[i] +
' is illegal value, treated as -1');
index[i] = -1;
}
}
tracePrint ('index.length=' + index.length);
tracePrint ('index=' + index);
if (index.length < 4)
{
alwaysPrint ('warning, index.length=' + index.length +
' insufficient to construct a triangle, ITFS ignored');
return;
}
j = 0; // coordIndexNew counter
coordIndexNew = new MFInt32 ();
// i walks through index array,
// goal is to initialize coordIndexNew list to match triangles
for (i=2; i <= index.length-1; i++)
{
if ((index[i] == index[i-1]) || (index[i] == index[i-2]) || (index[i-1] == index[i-2]))
{
alwaysPrint ('index=' + index);
alwaysPrint ('error, pair of equal indices in triangle');
return;
}
if (index[i] >= 0)
{
// add another triangle from latest 3 points of fan set to IFS
// swap order to ensure normal is ccw, i.e. in correct halfplane direction
coordIndexNew [coordIndexNew.length] = 0;
coordIndexNew [coordIndexNew.length] = index[i];
coordIndexNew [coordIndexNew.length] = index[i-1];
coordIndexNew [coordIndexNew.length] = -1; // terminate
}
else if (index[i] == -1) // finish current triangle, fan
{
// ensure done, or sufficient points remain to build another triangle
if ( (i!=index.length-1) && (index.length - i < 2))
{
alwaysPrint ('index=' + index);
alwaysPrint ('error, insufficient index values after' +
'index[' + i + ']=-1');
return;
}
// ensure done, or enough legal index values remain to build another triangle
if ( (i!=index.length-1) &&
((index[i+1] == -1) || (index[i+2] == -1) || (index[i+3] == -1)))
{
alwaysPrint ('index=' + index);
alwaysPrint ('error, insufficient non-negative-one index values after' +
'index[' + i + ']=-1');
return;
}
tracePrint ('encountered -1 in index array');
// skip ahead to build next fan set, no effect if done
if (i!=index.length-1) i = i + 2;
}
// incremental trace of array being built
tracePrint ('coordIndexNew=' + coordIndexNew);
}
renderedITFS.set_coordIndex = coordIndexNew;
tracePrint ('renderedITFS.coordIndex=' + renderedITFS.coordIndex);
// match colorIndex if any Color node exists
if (nodesHolder.color)
{
if (nodesHolder.color.color.length > 0)
{
renderedITFS.set_colorIndex = coordIndexNew;
tracePrint ('set_colorIndex=' + coordIndexNew);
}
}
}
function set_index (value, timestamp)
{
index = value;
initialize ();
}
function tracePrint(outputString)
{
if (localTraceEnabled)
Browser.println ('[IndexedTriangleFanSet]' + outputString);
}
function alwaysPrint(outputString)
{
Browser.println ('[IndexedTriangleFanSet]' + outputString);
}
]]>
</Script>
<Group>
<
MetadataString>
<IS>
<connect nodeField='metadata' protoField='metadata'/>
</IS>
</
MetadataString>
</Group>
</Group>
</ProtoBody>
</ProtoDeclare>
<!-- ==================== -->
<ProtoDeclare name='IndexedTriangleSet' appinfo='IndexedTriangleSet represents a 3D shape composed of a collection of individual triangles.'
>
<ProtoInterface>
<field name='ccw' type='SFBool' value='true' accessType='initializeOnly'/>
<field name='colorPerVertex' type='SFBool' value='true' accessType='initializeOnly'/>
<field name='normalPerVertex' type='SFBool' value='true' accessType='initializeOnly'/>
<field name='solid' type='SFBool' value='true' accessType='initializeOnly'/>
<field name='set_index' type='MFInt32' accessType='inputOnly'
appinfo='[0 infinity] or -1'
/>
<field name='index' type='MFInt32' accessType='initializeOnly'
appinfo='[0 infinity] or -1'
>
<!-- default initialization is NULL array [] to match X3D specification -->
</field>
<field name='color' type='SFNode' accessType='inputOutput'
appinfo='Color ColorRGBA node only'
>
<!-- default initialization is NULL node to match X3D specification -->
</field>
<field name='coord' type='SFNode' accessType='inputOutput'
appinfo='Coordinate node only'
>
<!-- default initialization is NULL node to match X3D specification -->
</field>
<field name='normal' type='SFNode' accessType='inputOutput'
appinfo='Normal node only'
>
<!-- default initialization is NULL node to match X3D specification -->
</field>
<field name='texCoord' type='SFNode' accessType='inputOutput'
appinfo='TextureCoordinate node only'
>
<!-- default initialization is NULL node to match X3D specification -->
</field>
<field name='metadata' type='SFNode' accessType='inputOutput'
appinfo='Metadata node only'
>
<!-- default initialization is NULL node to match X3D specification -->
</field>
</ProtoInterface>
<ProtoBody>
<IndexedFaceSet DEF='RenderedITS'>
<IS>
<connect nodeField='ccw' protoField='ccw'/>
<connect nodeField='normalPerVertex' protoField='normalPerVertex'/>
<connect nodeField='solid' protoField='solid'/>
<connect nodeField='color' protoField='color'/>
<connect nodeField='coord' protoField='coord'/>
<connect nodeField='normal' protoField='normal'/>
<connect nodeField='texCoord' protoField='texCoord'/>
</IS>
</IndexedFaceSet>
<Group DEF='UnrenderedITS'>
<Shape>
<!-- is this really needed at all?? -->
<IndexedFaceSet DEF='NodesHolderITS'>
<IS>
<connect nodeField='color' protoField='color'/>
<connect nodeField='coord' protoField='coord'/>
<connect nodeField='normal' protoField='normal'/>
<connect nodeField='texCoord' protoField='texCoord'/>
</IS>
</IndexedFaceSet>
</Shape>
<Script DEF='IndexedTriangleSetToIndexedFaceSet' directOutput='true'>
<field name='index' type='MFInt32' accessType='initializeOnly'/>
<field name='set_index' type='MFInt32' accessType='inputOnly'/>
<field name='renderedITS' type='SFNode' accessType='initializeOnly'>
</field>
<field name='nodesHolder' type='SFNode' accessType='initializeOnly'>
</field>
<field name='localTraceEnabled' type='SFBool' value='true' accessType='initializeOnly'/>
<field name='coordIndexNew' type='MFInt32' accessType='initializeOnly'>
<!-- constructed during initialization -->
</field>
<IS>
<connect nodeField='index' protoField='index'/>
<connect nodeField='set_index' protoField='set_index'/>
</IS>
<![CDATA[
ecmascript:
function initialize()
{
// index is an array of triangle indices. The ordering of
// the vertices is ccw (counter-clockwise).
// ensure legal index values
for (ii=0; ii <= index.length-1; ii++)
{
if (index[ii] < -1)
{
alwaysPrint ('error, index[' + ii + ']=' + index[ii] +
' is illegal value');
return;
}
}
tracePrint ('index.length=' + index.length);
tracePrint ('index=' + index);
if (index.length < 3)
{
alwaysPrint ('warning, index.length=' + index.length +
' insufficient to construct a triangle, ITS ignored');
return;
}
coordIndexNew = new MFInt32 ();
// ii walks through index array,
// goal is to initialize coordIndexNew list to match triangles
for (ii=0; ii <= index.length-1; ii+=3)
{
if ((index[ii] == index[ii+1]) || (index[ii] == index[ii+2]) || (index[ii+1] == index[ii+2]))
{
alwaysPrint ('index=' + index);
alwaysPrint ('error, pair of equal indices in triangle');
return;
}
if (index[ii] >= 0)
{
// add another triangle from latest 3 points of fan set to ITS
// order is ccw, i.e. in correct halfplane direction
coordIndexNew [coordIndexNew.length] = index[ii];
coordIndexNew [coordIndexNew.length] = index[ii+1];
coordIndexNew [coordIndexNew.length] = index[ii+2];
coordIndexNew [coordIndexNew.length] = -1;
}
if (index.length % 3 != 0) {
alwaysPrint ('error, index field does not contain a multiple' +
'of three coordinate values.');
alwaysPrint ('The remaining vertices shall be ignored');
return;
}
// ensure done, or sufficient points remain to build another triangle
// if ( (i!=index.length-1) && (index.length - i < 2))
// {
// alwaysPrint ('index=' + index);
// alwaysPrint ('error, insufficient index values after' +
// 'index[' + i + ']=-1');
// return;
// }
// ensure done, or enough legal index values remain to build another triangle
// if ( (i!=index.length-1) &&
// ((index[i+1] == -1) || (index[i+2] == -1) || (index[i+3] == -1)))
// {
// alwaysPrint ('index=' + index);
// alwaysPrint ('error, insufficient non-negative-one index values after' +
// 'index[' + i + ']=-1');
// return;
// }
// incremental trace of array being built
tracePrint ('coordIndexNew=' + coordIndexNew);
}
renderedITS.coordIndex = coordIndexNew;
tracePrint ('renderedITS.coordIndex=' + renderedITS.coordIndex);
// match colorIndex if any Color node exists
if (nodesHolder.color)
{
if (nodesHolder.color.color.length > 0)
{
renderedITS.set_colorIndex = coordIndexNew;
tracePrint ('set_colorIndex=' + coordIndexNew);
}
}
}
function set_index (value, timestamp)
{
index = value;
initialize ();
}
function tracePrint(outputString)
{
if (localTraceEnabled)
Browser.println ('[IndexedTriangleSet]' + outputString);
}
function alwaysPrint(outputString)
{
Browser.println ('[IndexedTriangleSet]' + outputString);
}
]]>
</Script>
<Group>
<
MetadataString>
<IS>
<connect nodeField='metadata' protoField='metadata'/>
</IS>
</
MetadataString>
</Group>
</Group>
</ProtoBody>
</ProtoDeclare>
<!-- ==================== -->
<ProtoDeclare name='IndexedTriangleStripSet' appinfo='IndexedTriangleStripSet represents a 3D shape composed of strips of triangles.'
>
<ProtoInterface>
<field name='ccw' type='SFBool' value='true' accessType='initializeOnly'/>
<field name='colorPerVertex' type='SFBool' value='true' accessType='initializeOnly'/>
<field name='normalPerVertex' type='SFBool' value='true' accessType='initializeOnly'/>
<field name='solid' type='SFBool' value='true' accessType='initializeOnly'/>
<field name='set_index' type='MFInt32' accessType='inputOnly'/>
<field name='index' type='MFInt32' accessType='initializeOnly'>
<!-- default initialization is NULL array [] to match X3D specification -->
</field>
<field name='color' type='SFNode' accessType='inputOutput'
appinfo='Color ColorRGBA node only'
>
<!-- default initialization is NULL node to match X3D specification -->
</field>
<field name='coord' type='SFNode' accessType='inputOutput'
appinfo='Coordinate node only'
>
<!-- default initialization is NULL node to match X3D specification -->
</field>
<field name='normal' type='SFNode' accessType='inputOutput'
appinfo='Normal node only'
>
<!-- default initialization is NULL node to match X3D specification -->
</field>
<field name='texCoord' type='SFNode' accessType='inputOutput'
appinfo='TextureCoordinate node only'
>
<!-- default initialization is NULL node to match X3D specification -->
</field>
<field name='metadata' type='SFNode' accessType='inputOutput'
appinfo='Metadata node only'
>
<!-- default initialization is NULL node to match X3D specification -->
</field>
</ProtoInterface>
<ProtoBody>
<IndexedFaceSet DEF='RenderedTSS'>
<IS>
<connect nodeField='ccw' protoField='ccw'/>
<connect nodeField='normalPerVertex' protoField='normalPerVertex'/>
<connect nodeField='solid' protoField='solid'/>
<connect nodeField='color' protoField='color'/>
<connect nodeField='coord' protoField='coord'/>
<connect nodeField='normal' protoField='normal'/>
<connect nodeField='texCoord' protoField='texCoord'/>
</IS>
</IndexedFaceSet>
<Group>
<Shape>
<!-- is this really needed at all?? -->
<IndexedFaceSet DEF='NodesHolderTSS'>
<IS>
<connect nodeField='color' protoField='color'/>
<connect nodeField='coord' protoField='coord'/>
<connect nodeField='normal' protoField='normal'/>
<connect nodeField='texCoord' protoField='texCoord'/>
</IS>
</IndexedFaceSet>
</Shape>
<Script DEF='IndexedTriangleStripSetToIndexedFaceSet' directOutput='true'>
<field name='index' type='MFInt32' accessType='initializeOnly'/>
<field name='set_index' type='MFInt32' accessType='inputOnly'/>
<field name='renderedTSS' type='SFNode' accessType='initializeOnly'>
</field>
<field name='nodesHolder' type='SFNode' accessType='initializeOnly'>
</field>
<field name='localTraceEnabled' type='SFBool' value='true' accessType='initializeOnly'/>
<field name='coordIndexNew' type='MFInt32' accessType='initializeOnly'>
<!-- constructed during initialization -->
</field>
<IS>
<connect nodeField='index' protoField='index'/>
<connect nodeField='set_index' protoField='set_index'/>
</IS>
<![CDATA[
ecmascript:
function initialize()
{
// index is an array of triangle indices. The ordering of
// the vertices is ccw (counter-clockwise).
// ensure legal index values
for (ii=0; ii <= index.length-1; ii++)
{
if (index[ii] < -1)
{
alwaysPrint ('error, index[' + ii + ']=' + index[ii] +
' is illegal value');
return;
}
}
tracePrint ('index.length=' + index.length);
tracePrint ('index=' + index);
if (index.length < 3)
{
alwaysPrint ('warning, index.length=' + index.length +
' insufficient to construct a triangle, ITS ignored');
return;
}
coordIndexNew = new MFInt32 ();
// ii walks through index array,
// goal is to initialize coordIndexNew list to match triangles
for (ii=2; ii <= index.length-1; ii++)
{
if ((index[ii] == index[ii-1]) || (index[ii] == index[ii-2]) || (index[ii-1] == index[ii-2]))
{
alwaysPrint ('index=' + index);
alwaysPrint ('error, pair of equal indices in triangle');
return;
}
if (index[ii] >= 0)
{
// add another triangle from latest 3 points of fan set to ITS
// order is ccw, i.e. in correct halfplane direction
coordIndexNew [coordIndexNew.length] = index[ii-2];
coordIndexNew [coordIndexNew.length] = index[ii-1];
coordIndexNew [coordIndexNew.length] = index[ii];
coordIndexNew [coordIndexNew.length] = -1;
}
// ensure done, or sufficient points remain to build another triangle
// if ( (i!=index.length-1) && (index.length - i < 2))
// {
// alwaysPrint ('index=' + index);
// alwaysPrint ('error, insufficient index values after' +
// 'index[' + i + ']=-1');
// return;
// }
// ensure done, or enough legal index values remain to build another triangle
// if ( (i!=index.length-1) &&
// ((index[i+1] == -1) || (index[i+2] == -1) || (index[i+3] == -1)))
// {
// alwaysPrint ('index=' + index);
// alwaysPrint ('error, insufficient non-negative-one index values after' +
// 'index[' + i + ']=-1');
// return;
// }
// incremental trace of array being built
tracePrint ('TSScoordIndexNew=' + coordIndexNew);
}
renderedTSS.set_coordIndex = coordIndexNew;
tracePrint ('renderedTSS.coordIndex=' + renderedTSS.coordIndex);
// match colorIndex if any Color node exists
if (nodesHolder.color)
{
if (nodesHolder.color.color.length > 0)
{
renderedTSS.set_colorIndex = coordIndexNew;
tracePrint ('set_colorIndex=' + coordIndexNew);
}
}
}
function set_index (value, timestamp)
{
index = value;
initialize ();
}
function tracePrint(outputString)
{
if (localTraceEnabled)
Browser.println ('[IndexedTriangleStripSet]' + outputString);
}
function alwaysPrint(outputString)
{
Browser.println ('[IndexedTriangleStripSet]' + outputString);
}
]]>
</Script>
<Group>
<
MetadataString>
<IS>
<connect nodeField='metadata' protoField='metadata'/>
</IS>
</
MetadataString>
</Group>
</Group>
</ProtoBody>
</ProtoDeclare>
<!-- ==================== -->
<ProtoDeclare name='LineSet' appinfo='LineSet represents a 3D geometry formed by constructing polylines from 3D vertices.'
>
<ProtoInterface>
<field name='vertexCount' type='MFInt32' accessType='inputOutput'>
<!-- default initialization is NULL array [] to match X3D specification -->
</field>
<field name='color' type='SFNode' accessType='inputOutput'
appinfo='Color ColorRGBA node only'
>
<!-- default initialization is NULL node to match X3D specification -->
</field>
<field name='coord' type='SFNode' accessType='inputOutput'
appinfo='Coordinate node only'
>
<!-- default initialization is NULL node to match X3D specification -->
</field>
<field name='metadata' type='SFNode' accessType='inputOutput'
appinfo='Metadata node only'
>
<!-- default initialization is NULL node to match X3D specification -->
</field>
</ProtoInterface>
<ProtoBody>
<IndexedLineSet DEF='RenderedILS'>
<IS>
<connect nodeField='color' protoField='color'/>
</IS>
</IndexedLineSet>
<Group>
<Shape>
<IndexedLineSet DEF='NodesHolderILS'>
<IS>
<connect nodeField='color' protoField='color'/>
<connect nodeField='coord' protoField='coord'/>
</IS>
</IndexedLineSet>
<Appearance DEF='UnusedAppearance'>
<Material emissiveColor='0.8 0.8 0.8'/>
</Appearance>
</Shape>
<Script DEF='LineSetToIndexedLineSet' directOutput='true'>
<field name='vertexCount' type='MFInt32' accessType='inputOutput'>
<!-- default initialization is NULL array [] to match X3D specification -->
</field>
<field name='renderedILS' type='SFNode' accessType='initializeOnly'>
</field>
<field name='nodesHolder' type='SFNode' accessType='initializeOnly'>
</field>
<field name='localTraceEnabled' type='SFBool' value='true' accessType='initializeOnly'/>
<field name='coordIndexNew' type='MFInt32' accessType='initializeOnly'>
<!-- constructed during initialization -->
</field>
<IS>
<connect nodeField='vertexCount' protoField='vertexCount'/>
</IS>
<![CDATA[
ecmascript:
function initialize()
{
vertexCountSum = 0;
tracePrint ('vertexCount=' + vertexCount);
for (i=0; i < vertexCount.length; i++)
{
if (vertexCount[i] < 2)
{
alwaysPrint ('error, vertexCount[' + i + ']=' + vertexCount[i] +
' is illegal value, must be >= 2');
return;
}
vertexCountSum = vertexCountSum + vertexCountSum[i];
}
tracePrint ('vertexCountSum=' + vertexCountSum);
numberPoints = nodesHolder.coord.point.length;
if (numberPoints < vertexCountSum)
{
alwaysPrint ('warning, Coordinate.point.length=' + numberPoints +
' is less than vertexCountSum=' + vertexCountSum + ', LS ignored');
return;
}
coordIndexNew = new MFInt32 ();
numberSegments = vertexCountSum.length; // need validity check
// i walks through array of points to build line-segment indices
i = 0;
for (seg=0; seg < numberSegments; seg++)
{
for (j=0; j < vertexCount[seg]; j++)
{
coordIndexNew [coordIndexNew.length] = i;
i++;
}
coordIndexNew [coordIndexNew.length] = -1; // terminate current fan
// incremental trace of array being built
tracePrint ('coordIndexNew=' + coordIndexNew);
} // repeat for all vertices
renderedILS.coordIndex = coordIndexNew;
tracePrint ('renderedILS.coordIndex=' + renderedILS.coordIndex);
// match colorIndex if any Color node exists
if (nodesHolder.color)
{
if (nodesHolder.color.color.length > 0)
{
renderedILS.colorIndex = coordIndexNew;
tracePrint ('set_colorIndex=' + coordIndexNew);
}
}
}
function tracePrint(outputString)
{
if (localTraceEnabled)
Browser.println ('[TriangleFanSet]' + outputString);
}
function alwaysPrint(outputString)
{
Browser.println ('[TriangleFanSet]' + outputString);
}
]]>
</Script>
<Group>
<
MetadataString>
<IS>
<connect nodeField='metadata' protoField='metadata'/>
</IS>
</
MetadataString>
</Group>
</Group>
</ProtoBody>
</ProtoDeclare>
<!-- ==================== -->
<ProtoDeclare name='TriangleFanSet' appinfo='TriangleFanSet represents a 3D shape composed of triangles that form a fan shape around the first vertex declared in each fan.'
>
<ProtoInterface>
<field name='fanCount' type='MFInt32' accessType='inputOutput'>
<!-- default initialization is NULL array [] to match X3D specification -->
</field>
<field name='ccw' type='SFBool' value='true' accessType='initializeOnly'/>
<field name='colorPerVertex' type='SFBool' value='true' accessType='initializeOnly'/>
<field name='normalPerVertex' type='SFBool' value='true' accessType='initializeOnly'/>
<field name='solid' type='SFBool' value='true' accessType='initializeOnly'/>
<field name='color' type='SFNode' accessType='inputOutput'
appinfo='Color ColorRGBA node only'
>
<!-- default initialization is NULL node to match X3D specification -->
</field>
<field name='coord' type='SFNode' accessType='inputOutput'
appinfo='Coordinate node only'
>
<!-- default initialization is NULL node to match X3D specification -->
</field>
<field name='normal' type='SFNode' accessType='inputOutput'
appinfo='Normal node only'
>
<!-- default initialization is NULL node to match X3D specification -->
</field>
<field name='texCoord' type='SFNode' accessType='inputOutput'
appinfo='TextureCoordinate node only'
>
<!-- default initialization is NULL node to match X3D specification -->
</field>
<field name='metadata' type='SFNode' accessType='inputOutput'
appinfo='Metadata node only'
>
<!-- default initialization is NULL node to match X3D specification -->
</field>
</ProtoInterface>
<ProtoBody>
<IndexedFaceSet DEF='RenderedTFS'>
<IS>
<connect nodeField='ccw' protoField='ccw'/>
<connect nodeField='colorPerVertex' protoField='colorPerVertex'/>
<connect nodeField='normalPerVertex' protoField='normalPerVertex'/>
<connect nodeField='solid' protoField='solid'/>
<connect nodeField='color' protoField='color'/>
<connect nodeField='coord' protoField='coord'/>
<connect nodeField='normal' protoField='normal'/>
<connect nodeField='texCoord' protoField='texCoord'/>
</IS>
</IndexedFaceSet>
<Group DEF='UnrenderedTFS'>
<Shape>
<!-- is this really needed at all?? -->
<IndexedFaceSet DEF='NodesHolderTFS'>
<IS>
<connect nodeField='color' protoField='color'/>
<connect nodeField='coord' protoField='coord'/>
<connect nodeField='normal' protoField='normal'/>
<connect nodeField='texCoord' protoField='texCoord'/>
</IS>
</IndexedFaceSet>
</Shape>
<Script DEF='TriangleFanSetToIndexedFaceSet' directOutput='true'>
<field name='fanCount' type='MFInt32' accessType='inputOutput'>
<!-- default initialization is NULL array [] to match X3D specification -->
</field>
<field name='renderedTFS' type='SFNode' accessType='initializeOnly'>
</field>
<field name='nodesHolder' type='SFNode' accessType='initializeOnly'>
</field>
<field name='localTraceEnabled' type='SFBool' value='true' accessType='initializeOnly'/>
<field name='coordIndexNew' type='MFInt32' accessType='initializeOnly'>
<!-- constructed during initialization -->
</field>
<IS>
<connect nodeField='fanCount' protoField='fanCount'/>
</IS>
<![CDATA[
ecmascript:
function initialize()
{
fanCountSum = 0;
tracePrint ('fanCount=' + fanCount);
for (i=0; i < fanCount.length; i++)
{
if (fanCount[i] < 3)
{
alwaysPrint ('error, fanCount[' + i + ']=' + fanCount[i] +
' is illegal value, must be >= 3');
return;
}
fanCountSum = fanCountSum + fanCount[i];
}
tracePrint ('fanCountSum=' + fanCountSum);
numberPoints = nodesHolder.coord.point.length;
if (numberPoints < fanCountSum)
{
alwaysPrint ('warning, Coordinate.point.length=' + numberPoints +
' is less than fanCountSum=' + fanCountSum + ', TFS ignored');
return;
}
coordIndexNew = new MFInt32 ();
numberFans = fanCount.length; // need validity check
// i walks through array of points to build polygon indices
i = 0;
for (fan=0; fan < numberFans; fan++)
{
for (j=0; j < fanCount[fan]; j++)
{
coordIndexNew [coordIndexNew.length] = i;
i++;
}
coordIndexNew [coordIndexNew.length] = -1; // terminate current fan
// incremental trace of array being built
tracePrint ('coordIndexNew=' + coordIndexNew);
} // repeat for all fans
renderedTFS.coordIndex = coordIndexNew;
tracePrint ('renderedTFS.coordIndex=' + renderedTFS.coordIndex);
// match colorIndex if any Color node exists
if (nodesHolder.color)
{
if (nodesHolder.color.color.length > 0)
{
renderedTFS.set_colorIndex = coordIndexNew;
tracePrint ('set_colorIndex=' + coordIndexNew);
}
}
}
function tracePrint(outputString)
{
if (localTraceEnabled)
Browser.println ('[TriangleFanSet]' + outputString);
}
function alwaysPrint(outputString)
{
Browser.println ('[TriangleFanSet]' + outputString);
}
]]>
</Script>
<Group>
<
MetadataString>
<IS>
<connect nodeField='metadata' protoField='metadata'/>
</IS>
</
MetadataString>
</Group>
</Group>
</ProtoBody>
</ProtoDeclare>
<!-- ==================== -->
<ProtoDeclare name='TriangleSet' appinfo='TriangleSet represents a 3D shape that represents a collection of individual triangles.'
>
<ProtoInterface>
<field name='ccw' type='SFBool' value='true' accessType='initializeOnly'/>
<field name='colorPerVertex' type='SFBool' value='true' accessType='initializeOnly'/>
<field name='normalPerVertex' type='SFBool' value='true' accessType='initializeOnly'/>
<field name='solid' type='SFBool' value='true' accessType='initializeOnly'/>
<field name='color' type='SFNode' accessType='inputOutput'
appinfo='Color ColorRGBA node only'
>
<!-- default initialization is NULL node to match X3D specification -->
</field>
<field name='coord' type='SFNode' accessType='inputOutput'
appinfo='Coordinate node only'
>
<!-- default initialization is NULL node to match X3D specification -->
</field>
<field name='normal' type='SFNode' accessType='inputOutput'
appinfo='Normal node only'
>
<!-- default initialization is NULL node to match X3D specification -->
</field>
<field name='texCoord' type='SFNode' accessType='inputOutput'
appinfo='TextureCoordinate node only'
>
<!-- default initialization is NULL node to match X3D specification -->
</field>
<field name='metadata' type='SFNode' accessType='inputOutput'
appinfo='Metadata node only'
>
<!-- default initialization is NULL node to match X3D specification -->
</field>
</ProtoInterface>
<ProtoBody>
<IndexedFaceSet DEF='RenderedTS'>
<IS>
<connect nodeField='ccw' protoField='ccw'/>
<connect nodeField='normalPerVertex' protoField='normalPerVertex'/>
<connect nodeField='solid' protoField='solid'/>
<connect nodeField='color' protoField='color'/>
<connect nodeField='coord' protoField='coord'/>
<connect nodeField='normal' protoField='normal'/>
<connect nodeField='texCoord' protoField='texCoord'/>
</IS>
</IndexedFaceSet>
<Group DEF='UnrenderedTS'>
<Shape>
<!-- is this really needed at all?? -->
<IndexedFaceSet DEF='NodesHolderTS'>
<IS>
<connect nodeField='color' protoField='color'/>
<connect nodeField='coord' protoField='coord'/>
<connect nodeField='normal' protoField='normal'/>
<connect nodeField='texCoord' protoField='texCoord'/>
</IS>
</IndexedFaceSet>
</Shape>
<Script DEF='TriangleSetToIndexedFaceSet' directOutput='true'>
<field name='index' type='MFInt32' accessType='initializeOnly'>
<!-- default initialization is NULL -->
</field>
<field name='set_index' type='MFInt32' accessType='inputOnly'/>
<field name='renderedTS' type='SFNode' accessType='initializeOnly'>
</field>
<field name='nodesHolder' type='SFNode' accessType='initializeOnly'>
</field>
<field name='localTraceEnabled' type='SFBool' value='true' accessType='initializeOnly'/>
<field name='coordIndexNew' type='MFInt32' accessType='initializeOnly'>
<!-- constructed during initialization -->
</field>
<![CDATA[
ecmascript:
function initialize()
{
// index is an array of triangle indices. The ordering of
// the vertices is ccw (counter-clockwise).
// ensure legal index values
for (ii=0; ii <= index.length-1; ii++)
{
if (index[ii] < -1)
{
alwaysPrint ('error, index[' + ii + ']=' + index[ii] +
' is illegal value');
return;
}
}
tracePrint ('index.length=' + index.length);
tracePrint ('index=' + index);
if (index.length < 3)
{
alwaysPrint ('warning, index.length=' + index.length +
' insufficient to construct a triangle, ITS ignored');
return;
}
coordIndexNew = new MFInt32 ();
// ii walks through index array,
// goal is to initialize coordIndexNew list to match triangles
for (ii=0; ii <= index.length-1; ii+=3)
{
if ((index[ii] == index[ii+1]) || (index[ii] == index[ii+2]) || (index[ii+1] == index[ii+2]))
{
alwaysPrint ('index=' + index);
alwaysPrint ('error, pair of equal indices in triangle');
return;
}
if (index[ii] >= 0)
{
// add another triangle from latest 3 points of fan set to ITS
// order is ccw, i.e. in correct halfplane direction
coordIndexNew [coordIndexNew.length] = index[ii];
coordIndexNew [coordIndexNew.length] = index[ii+1];
coordIndexNew [coordIndexNew.length] = index[ii+2];
coordIndexNew [coordIndexNew.length] = -1;
}
if (index.length % 3 != 0) {
alwaysPrint ('error, index field does not contain a multiple' +
'of three coordinate values.');
alwaysPrint ('The remaining vertices shall be ignored');
return;
}
// ensure done, or sufficient points remain to build another triangle
// if ( (i!=index.length-1) && (index.length - i < 2))
// {
// alwaysPrint ('index=' + index);
// alwaysPrint ('error, insufficient index values after' +
// 'index[' + i + ']=-1');
// return;
// }
// ensure done, or enough legal index values remain to build another triangle
// if ( (i!=index.length-1) &&
// ((index[i+1] == -1) || (index[i+2] == -1) || (index[i+3] == -1)))
// {
// alwaysPrint ('index=' + index);
// alwaysPrint ('error, insufficient non-negative-one index values after' +
// 'index[' + i + ']=-1');
// return;
// }
// incremental trace of array being built
tracePrint ('coordIndexNew=' + coordIndexNew);
}
renderedITS.set_coordIndex = coordIndexNew;
tracePrint ('renderedITS.coordIndex=' + renderedITS.coordIndex);
// match colorIndex if any Color node exists
if (nodesHolder.color)
{
if (nodesHolder.color.color.length > 0)
{
renderedITS.set_colorIndex = coordIndexNew;
tracePrint ('set_colorIndex=' + coordIndexNew);
}
}
}
function set_index (value, timestamp)
{
index = value;
initialize ();
}
function tracePrint(outputString)
{
if (localTraceEnabled)
Browser.println ('[IndexedTriangleSet]' + outputString);
}
function alwaysPrint(outputString)
{
Browser.println ('[IndexedTriangleSet]' + outputString);
}
]]>
</Script>
<Group>
<
MetadataString>
<IS>
<connect nodeField='metadata' protoField='metadata'/>
</IS>
</
MetadataString>
</Group>
</Group>
</ProtoBody>
</ProtoDeclare>
<!-- ==================== -->
<ProtoDeclare name='TriangleStripSet' appinfo='TriangleStripSet represents a 3D shape composed of strips of triangles.'
>
<ProtoInterface>
<field name='stripCount' type='MFInt32' accessType='inputOutput'>
<!-- default initialization is NULL array [] to match X3D specification -->
</field>
<field name='ccw' type='SFBool' value='true' accessType='initializeOnly'/>
<field name='colorPerVertex' type='SFBool' value='true' accessType='initializeOnly'/>
<field name='normalPerVertex' type='SFBool' value='true' accessType='initializeOnly'/>
<field name='solid' type='SFBool' value='true' accessType='initializeOnly'/>
<field name='color' type='SFNode' accessType='inputOutput'
appinfo='Color ColorRGBA node only'
>
<!-- default initialization is NULL node to match X3D specification -->
</field>
<field name='coord' type='SFNode' accessType='inputOutput'
appinfo='Coordinate node only'
>
<!-- default initialization is NULL node to match X3D specification -->
</field>
<field name='normal' type='SFNode' accessType='inputOutput'
appinfo='Normal node only'
>
<!-- default initialization is NULL node to match X3D specification -->
</field>
<field name='texCoord' type='SFNode' accessType='inputOutput'
appinfo='TextureCoordinate node only'
>
<!-- default initialization is NULL node to match X3D specification -->
</field>
<field name='metadata' type='SFNode' accessType='inputOutput'
appinfo='Metadata node only'
>
<!-- default initialization is NULL node to match X3D specification -->
</field>
</ProtoInterface>
<ProtoBody>
<IndexedFaceSet/>
</ProtoBody>
</ProtoDeclare>
<!-- ==================== -->
<!-- ProtoInstance examples are found in RenderingComponentExamples.x3d -->
<Background groundColor='0.2 0.2 0.2' skyColor='0.2 0.2 0.2'/>
<Anchor DEF='LinkToExamples' description='link to examples'
url='
RenderingComponentExamples.x3d"https://www.web3d.org/x3d/content/examples/Basic/development/RenderingComponentExamples.x3d" "RenderingComponentExamples.wrl" "https://www.web3d.org/x3d/content/examples/Basic/development/RenderingComponentExamples.wrl" '
>
<Shape>
<Appearance>
<Material diffuseColor='1 1 1'/>
</Appearance>
<Text string='"RenderingComponentPrototypes" "is a developmental file." "Click this text to view" "RenderingComponentExamples"'>
<FontStyle justify='"MIDDLE" "MIDDLE"'/>
</Text>
</Shape>
<!-- Selectable Text has transparent Box and TouchSensor description as a tooltip -->
<Shape>
<Box size='12 5 .001'/>
<Appearance>
<Material transparency='0.8'/>
</Appearance>
</Shape>
</Anchor>
</Scene>