X3D Model Documentation: Arc2dComponentPrototype.x3d

  1  <?xml version="1.0" encoding="UTF-8"?>
  2  <!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.1//EN" "https://www.web3d.org/specifications/x3d-3.1.dtd">
  3  <X3D profile='Immersive' version='3.1 xmlns:xsd='http://www.w3.org/2001/XMLSchema-instance' xsd:noNamespaceSchemaLocation='https://www.web3d.org/specifications/x3d-3.1.xsd'>
  4       <head>
  5            <meta name='titlecontent='Arc2dComponentPrototype.x3d'/>
  6            <meta name='descriptioncontent='X3D Geometry2D component node, implemented as prototype for backwards compatibility with VRML 97. Arc2D specifies a 2D linear circular arc.'/>
  7            <meta name='creatorcontent='Christos Kalogrias, Don Brutzman, Ken Curtin, Duane Davis'/>
  8            <meta name='createdcontent='14 November 2003'/>
  9            <meta name='modifiedcontent='20 October 2019'/>
 10            <meta name='referencecontent='https://www.web3d.org/specifications/X3Dv4/ISO-IEC19775-1v4-IS/Part01/components/geometry2D.html'/>
 11            <meta name='subjectcontent='Geometry2D component node (Arc2D)'/>
 12            <meta name='identifiercontent='https://www.web3d.org/x3d/content/examples/Basic/development/Arc2dComponentPrototype.x3d'/>
 13            <meta name='generatorcontent='X3D-Edit 3.3, https://savage.nps.edu/X3D-Edit'/>
 14            <meta name='licensecontent='../license.html'/>
 15       </head>
<!--

<!--
Event Graph ROUTE Table shows event connections.
-->

<!-- to top Index for DEF nodes: Arc2dToFaceSet3d, Arc3DPoints, ArcIndexPoints

Index for ProtoDeclare definition: Arc2D
-->
 16       <Scene>
 17            <!-- ==================== -->
 18            <WorldInfo title='Arc2dComponentPrototype.x3d'/>
 19            <ProtoDeclare name='Arc2D'>
 20                 <ProtoInterface>
 21                      <field name='startAngletype='SFFloatvalue='0accessType='initializeOnly'/>
 22                      <field name='endAngletype='SFFloatvalue='1.5707963265accessType='initializeOnly'/>
 23                      <field name='radiustype='SFFloatvalue='1accessType='initializeOnly'/>
 24                      <field name='metadatatype='SFNodeaccessType='inputOutput'
                     appinfo='Metadata node only'/>
 25                 </ProtoInterface>
 26                 <ProtoBody>
 27                      <!-- Only the first node counts as the node type of a prototype. This node must be a geometry node. -->
 28 
                    <!-- ROUTE information for ArcIndexPoints node:  [from Arc2dToFaceSet3d.arcIndexSet3d to set_coordIndex ] -->
                    <IndexedLineSet DEF='ArcIndexPoints'>
 29 
                         <!-- ROUTE information for Arc3DPoints node:  [from Arc2dToFaceSet3d.arcSet3d to point ] -->
                         <Coordinate DEF='Arc3DPoints'/>
 30                      </IndexedLineSet>
 31                      <!-- Any nodes after initial node in a ProtoBody is not rendered. -->
 32                      <Group>
 33                           <IS>
 34                                <connect nodeField='metadataprotoField='metadata'/>
 35                           </IS>
 36 
                         <!-- ROUTE information for Arc2dToFaceSet3d node:  [from arcSet3d to Arc3DPoints.point ] [from arcIndexSet3d to ArcIndexPoints.set_coordIndex ] -->
                         <Script DEF='Arc2dToFaceSet3d'>
 37                                <field name='startAngletype='SFFloataccessType='initializeOnly'/>
 38                                <field name='endAngletype='SFFloataccessType='initializeOnly'/>
 39                                <field name='radiustype='SFFloataccessType='initializeOnly'/>
 40                                <field name='arcSet3dtype='MFVec3faccessType='outputOnly'/>
 41                                <field name='arcIndexSet3dtype='MFInt32accessType='outputOnly'/>
 42                                <IS>
 43                                     <connect nodeField='startAngleprotoField='startAngle'/>
 44                                     <connect nodeField='endAngleprotoField='endAngle'/>
 45                                     <connect nodeField='radiusprotoField='radius'/>
 46                                </IS>
  <![CDATA[
            
ecmascript:

function initialize()
{
   numOfPoints = 100;

   if (radius < 0)
   {
      Browser.println ('[Arc2D] Warning:  invalid value, radius=' + value + ' must instead be >= 0');
   }

   if ((startAngle < 0) || (startAngle >= 2 * Math.PI))
   {
      Browser.println ('[Arc2D] Warning: startAngle=' + startAngle + ' must be within range [0..2pi)');
   }

   if ((endAngle < 0) || (endAngle >= 2 * Math.PI))
   {
      Browser.println ('[Arc2D] Warning: endAngle=' + endAngle + ' must be within range [0..2pi)');
   }

   // equal startAngle, endAngle means draw full circle.
   // high out-of-range endAngle is OK for local computation.
   if (startAngle >= endAngle)
      endAngle += (2 * Math.PI);

   differAng = Math.abs((endAngle - startAngle))/numOfPoints;

   for (i = 0; i <= numOfPoints; i++)
   {
      arcSet3d[i] = new SFVec3f (radius * Math.cos(startAngle + i * differAng), radius * Math.sin(startAngle + i * differAng), 0.0);
      arcIndexSet3d[i] = i;
   }

} // initialize

          
]]>
 48                           </Script>
 49                           < ROUTE  fromNode='Arc2dToFaceSet3d' fromField='arcSet3d' toNode='Arc3DPoints' toField='point'/>
 50                           < ROUTE  fromNode='Arc2dToFaceSet3d' fromField='arcIndexSet3d' toNode='ArcIndexPoints' toField='set_coordIndex'/>
 51                      </Group>
 52                 </ProtoBody>
 53            </ProtoDeclare>
 54       </Scene>
 55  </X3D>
<!--

<!--
Event Graph ROUTE Table shows event connections.
-->

<!-- to top Index for DEF nodes: Arc2dToFaceSet3d, Arc3DPoints, ArcIndexPoints

Index for ProtoDeclare definition: Arc2D
-->
X3D Tooltips element index: connect, Coordinate, field, Group, head, IndexedLineSet, IS, meta, ProtoBody, ProtoDeclare, ProtoInterface, ROUTE, Scene, Script, WorldInfo, X3D, accessType and type, XML data types, field types

Event Graph ROUTE Table with 2 ROUTE connections total, showing X3D event-model relationships for this scene.

Each row shows an event cascade that may occur during a single timestamp interval between frame renderings, as part of the X3D execution model.

Arc2dToFaceSet3d
Script
arcSet3d
MFVec3f

ROUTE
event to
(1)
Arc3DPoints
Coordinate
point
MFVec3f
Arc2dToFaceSet3d
Script
arcIndexSet3d
MFInt32

ROUTE
event to
(1)
ArcIndexPoints
IndexedLineSet
set_coordIndex
MFInt32
Additional guidance on X3D animation can be found in the 10-Step Animation Design Process and Event Tracing hint sheets. Have fun with X3D! 😀

-->
<!-- Online at
https://www.web3d.org/x3d/content/examples/Basic/development/Arc2dComponentPrototypeIndex.html -->
<!-- Version control at
https://sourceforge.net/p/x3d/code/HEAD/tree/www.web3d.org/x3d/content/examples/Basic/development/Arc2dComponentPrototype.x3d -->

<!-- Color legend: X3D terminology <X3dNode DEF='idName' field='value'/> matches XML terminology <XmlElement DEF='idName' attribute='value'/>
(Light-blue background: event-based behavior node or statement) (Grey background inside box: inserted documentation) (Magenta background: X3D Extensibility)
    <ProtoDeclare name='ProtoName'> <field name='fieldName'/> </ProtoDeclare> -->

to top <!-- For additional help information about X3D scenes, please see X3D Tooltips, X3D Resources, and X3D Scene Authoring Hints. -->