X3D Model Documentation: SceneNodePrototype.x3d

  1  <?xml version="1.0" encoding="UTF-8"?>
  2 
<!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.0//EN" "https://www.web3d.org/specifications/x3d-3.0.dtd">
  3  <X3D profile='Immersive' version='3.0 xmlns:xsd='http://www.w3.org/2001/XMLSchema-instance' xsd:noNamespaceSchemaLocation='https://www.web3d.org/specifications/x3d-3.0.xsd'>
  4       <head>
  5            <meta name='titlecontent='SceneNodePrototype.x3d'/>
  6            <meta name='creatorcontent='Don Brutzman'/>
  7            <meta name='createdcontent='19 December 2000'/>
  8            <meta name='modifiedcontent='20 October 2019'/>
  9            <meta name='descriptioncontent='Expose functionality of Browser class in Java/ECMAscript annexes of VRML 97 specification. Consider promotion to a native node in X3D/VRML 200x scenes.'/>
 10            <meta name=' warning content=' Under development, many of these exposed attributes will be eliminated. Scene node will not be used in X3D proper, but may become a valuable prototype via SAI scripting. '/>
 11            <meta name='identifiercontent='https://www.web3d.org/x3d/content/examples/Basic/development/SceneNodePrototype.x3d'/>
 12            <meta name='generatorcontent='X3D-Edit 3.3, https://savage.nps.edu/X3D-Edit'/>
 13            <meta name='licensecontent='../license.html'/>
 14       </head>
<!--

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

<!-- to top Index for DEF nodes: AssembleBrowserOutputText, BrowserScript, ClickTextSensor, Output3dText, SceneNode

Index for ProtoDeclare definition: Scene
-->
 15       <Scene>
 16            <WorldInfo title='SceneNodePrototype.x3d'/>
 17            <ProtoDeclare name='Scene'>
 18                 <ProtoInterface>
 19                      <!-- Standard browser attributes exposed via VRML 97 Script annexes -->
 20                      <field name='createVrmlFromStringtype='SFStringaccessType='inputOnly'/>
 21                      <field name='createVrmlFromURLtype='SFStringaccessType='inputOnly'/>
 22                      <field name='createdVrmlNodestype='MFNodeaccessType='outputOnly'/>
 23                      <field name='currentFrameRatetype='SFFloataccessType='outputOnly'/>
 24                      <field name='currentSpeedtype='SFFloataccessType='outputOnly'/>
 25                      <field name='descriptiontype='SFStringaccessType='inputOnly'/>
 26                      <field name='evaluatetype='SFBoolaccessType='inputOnly'/>
 27                      <field name='loadUrltype='SFStringaccessType='inputOnly'/>
 28                      <field name='loadUrlParametertype='SFStringaccessType='inputOnly'/>
 29                      <field name='nametype='SFStringaccessType='outputOnly'/>
 30                      <field name='replaceWorldtype='MFNodeaccessType='inputOnly'/>
 31                      <field name='versiontype='SFStringaccessType='outputOnly'/>
 32                      <field name='worldUrltype='SFStringaccessType='outputOnly'/>
 33                      <field name='addRoutetype='SFBoolaccessType='inputOnly'/>
 34                      <field name='deleteRoutetype='SFBoolaccessType='inputOnly'/>
 35                      <field name='fromNodetype='SFNodeaccessType='inputOnly'/>
 36                      <field name='fromEventOuttype='SFStringaccessType='inputOnly'/>
 37                      <field name='toNodetype='SFNodeaccessType='inputOnly'/>
 38                      <field name='toEventIntype='SFStringaccessType='inputOnly'/>
 39                      <!-- Candidate additions -->
 40                      <field name='boundBackgroundtype='SFNodeaccessType='outputOnly'/>
 41                      <field name='boundFogtype='SFNodeaccessType='outputOnly'/>
 42                      <field name='boundGeoViewpointtype='SFNodeaccessType='outputOnly'/>
 43                      <field name='boundNavigationInfotype='SFNodeaccessType='outputOnly'/>
 44                      <field name='boundViewpointtype='SFNodeaccessType='outputOnly'/>
 45                      <field name='responsetype='MFStringaccessType='outputOnly'/>
 46                      <field name='dashboardVisibletype='SFBoolvalue='trueaccessType='inputOutput'/>
 47                      <field name='pixelWidthtype='SFInt32value='-1accessType='inputOutput'/>
 48                      <field name='pixelHeighttype='SFInt32value='-1accessType='inputOutput'/>
 49                 </ProtoInterface>
 50                 <ProtoBody>
 51                      <Script DEF='BrowserScriptdirectOutput='true'>
 52                           <field name='createVrmlFromStringtype='SFStringaccessType='inputOnly'/>
 53                           <field name='createVrmlFromURLtype='SFStringaccessType='inputOnly'/>
 54                           <field name='createdVrmlNodestype='MFNodeaccessType='outputOnly'/>
 55                           <field name='currentFrameRatetype='SFFloataccessType='outputOnly'/>
 56                           <field name='currentSpeedtype='SFFloataccessType='outputOnly'/>
 57                           <field name='descriptiontype='SFStringaccessType='inputOnly'/>
 58                           <field name='evaluatetype='SFBoolaccessType='inputOnly'/>
 59                           <field name='loadUrltype='SFStringaccessType='inputOnly'/>
 60                           <field name='loadUrlParametertype='SFStringaccessType='inputOnly'/>
 61                           <field name='nametype='SFStringaccessType='outputOnly'/>
 62                           <field name='replaceWorldtype='MFNodeaccessType='inputOnly'/>
 63                           <field name='versiontype='SFStringaccessType='outputOnly'/>
 64                           <field name='worldUrltype='SFStringaccessType='outputOnly'/>
 65                           <field name='addRoutetype='SFBoolaccessType='inputOnly'/>
 66                           <field name='deleteRoutetype='SFBoolaccessType='inputOnly'/>
 67                           <field name='fromNodetype='SFNodeaccessType='inputOnly'/>
 68                           <field name='fromEventOuttype='SFStringaccessType='inputOnly'/>
 69                           <field name='toNodetype='SFNodeaccessType='inputOnly'/>
 70                           <field name='toEventIntype='SFStringaccessType='inputOnly'/>
 71                           <field name='responsetype='MFStringaccessType='outputOnly'/>
 72                           <IS>
 73                                <connect nodeField='createVrmlFromStringprotoField='createVrmlFromString'/>
 74                                <connect nodeField='createVrmlFromURLprotoField='createVrmlFromURL'/>
 75                                <connect nodeField='createdVrmlNodesprotoField='createdVrmlNodes'/>
 76                                <connect nodeField='currentFrameRateprotoField='currentFrameRate'/>
 77                                <connect nodeField='currentSpeedprotoField='currentSpeed'/>
 78                                <connect nodeField='descriptionprotoField='description'/>
 79                                <connect nodeField='evaluateprotoField='evaluate'/>
 80                                <connect nodeField='loadUrlprotoField='loadUrl'/>
 81                                <connect nodeField='loadUrlParameterprotoField='loadUrlParameter'/>
 82                                <connect nodeField='nameprotoField='name'/>
 83                                <connect nodeField='replaceWorldprotoField='replaceWorld'/>
 84                                <connect nodeField='versionprotoField='version'/>
 85                                <connect nodeField='worldUrlprotoField='worldUrl'/>
 86                                <connect nodeField='addRouteprotoField='addRoute'/>
 87                                <connect nodeField='deleteRouteprotoField='deleteRoute'/>
 88                                <connect nodeField='fromNodeprotoField='fromNode'/>
 89                                <connect nodeField='fromEventOutprotoField='fromEventOut'/>
 90                                <connect nodeField='toNodeprotoField='toNode'/>
 91                                <connect nodeField='toEventInprotoField='toEventIn'/>
 92                                <connect nodeField='responseprotoField='response'/>
 93                           </IS>
  <![CDATA[
          
ecmascript:

function evaluate (inputValue, timeStamp)
{
	if (inputValue)  // Boolean
	{
		currentFrameRate = Browser.getCurrentFrameRate ();
		currentSpeed = Browser.getCurrentSpeed ();
		version = Browser.getVersion ();
		name = Browser.getName ();
		worldUrl = Browser.getWorldURL ();

		Browser.println ('currentFrameRate = ' + currentFrameRate);
		Browser.println ('currentSpeed = ' + currentSpeed);
		Browser.println ('version = ' + version);
		Browser.println ('name = ' + name);
		Browser.println ('worldUrl = ' + worldUrl);
	}
}

function createVrmlFromString (inputValue, timeStamp)
{
	// note VRML 97 method name didn't follow capitalization convention
	createdVrmlNodes = Browser.createVrmlFromString (inputValue);
}

function createVrmlFromUrl (inputValue, timeStamp)
{
	// note VRML 97 method name didn't follow capitalization convention
	createdVrmlNodes = Browser.createVrmlFromURL (inputValue);
}

function description (inputValue, timeStamp)
{
	Browser.println ('description = ' + inputValue);
	Browser.setDescription (inputValue);
}

function replaceWorld (inputValue, timeStamp)
{
	Browser.replaceWorld (inputValue);
}

function addRoute (inputValue, timeStamp)
{
	if (inputValue)  // Boolean
	{
		Browser.addRoute (fromNode, fromEventOut, toNode, toEventIn);
	}
}

function deleteRoute (inputValue, timeStamp)
{
	if (inputValue)  // Boolean
	{
		Browser.deleteRoute (fromNode, fromEventOut, toNode, toEventIn);
	}
}

function loadURL (inputValue, timeStamp)
{
	Browser.println ('loadURL = ' + inputValue);
	Browser.println ('loadUrlParameter = ' + loadUrlParameter);
	Browser.loadURL (inputValue, loadUrlParameter);
}
function createVrmlFromURL (SFStringValue, timestamp)
{

}

function loadUrl (SFStringValue, timestamp)
{

}

function loadUrlParameter (SFStringValue, timestamp)
{

}

function fromNode (SFNodeValue, timestamp)
{

}

function fromEventOut (SFStringValue, timestamp)
{

}

function toNode (SFNodeValue, timestamp)
{

}

function toEventIn (SFStringValue, timestamp)
{

}

        
]]>
 95                      </Script>
 96                 </ProtoBody>
 97            </ProtoDeclare>
 98            <!-- Example invocation -->
 99 
100            <Shape>
101 
               <!-- ROUTE information for Output3dText node:  [from AssembleBrowserOutputText.evaluatedResult to string ] -->
               <Text DEF='Output3dTextstring='"Click text for partial Scene node test"'>
102                      <FontStyle justify='"MIDDLE" "MIDDLE"size='0.5'/>
103                 </Text>
104                 <Appearance>
105                      <Material diffuseColor='0 0.6 0.6'/>
106                 </Appearance>
107            </Shape>
108 
          <!-- ROUTE information for ClickTextSensor node:  [from isActive to SceneNode.evaluate ] -->
          <TouchSensor DEF='ClickTextSensordescription='Click text for partial Scene node test'/>
109 
110                 <field name='currentFrameRatetype='SFFloataccessType='inputOnly'/>
111                 <field name='currentSpeedtype='SFFloataccessType='inputOnly'/>
112                 <field name='nametype='SFStringaccessType='inputOnly'/>
113                 <field name='versiontype='SFStringaccessType='inputOnly'/>
114                 <field name='worldUrltype='SFStringaccessType='inputOnly'/>
115                 <field name='evaluatedResulttype='MFStringaccessType='outputOnly'/>
  <![CDATA[
      
ecmascript:

function initialize ()
{
	evaluatedResult = new MFString (
		'Click for partial Scene node test:',
		' ', ' ', ' ', ' ', ' ', ' ', ' ');
}
function currentFrameRate (inputValue, timeStamp)
{
	evaluatedResult [2] = 'currentFrameRate=' + inputValue;
}
function currentSpeed (inputValue, timeStamp)
{
	evaluatedResult [3] = 'currentSpeed=' + inputValue;
}
function version (inputValue, timeStamp)
{
	evaluatedResult [4] = 'version=' + inputValue;
}
function name (inputValue, timeStamp)
{
	evaluatedResult [5] = 'name=' + inputValue;
}
function worldUrl (inputValue, timeStamp)
{
	evaluatedResult [6] = 'worldUrl=';
	evaluatedResult [7] = inputValue;
}

    
]]>
117            </Script>
118            < ROUTE  fromNode='ClickTextSensor' fromField='isActive' toNode='SceneNode' toField='evaluate'/>
119            < ROUTE  fromNode='SceneNode' fromField='currentFrameRate' toNode='AssembleBrowserOutputText' toField='currentFrameRate'/>
120            < ROUTE  fromNode='SceneNode' fromField='currentSpeed' toNode='AssembleBrowserOutputText' toField='currentSpeed'/>
121            < ROUTE  fromNode='SceneNode' fromField='version' toNode='AssembleBrowserOutputText' toField='version'/>
122            < ROUTE  fromNode='SceneNode' fromField='name' toNode='AssembleBrowserOutputText' toField='name'/>
123            < ROUTE  fromNode='SceneNode' fromField='worldUrl' toNode='AssembleBrowserOutputText' toField='worldUrl'/>
124            < ROUTE  fromNode='AssembleBrowserOutputText' fromField='evaluatedResult' toNode='Output3dText' toField='string'/>
125       </Scene>
126  </X3D>
<!--

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

<!-- to top Index for DEF nodes: AssembleBrowserOutputText, BrowserScript, ClickTextSensor, Output3dText, SceneNode

Index for ProtoDeclare definition: Scene
-->
X3D Tooltips element index: Appearance, connect, field, FontStyle, head, IS, Material, meta, ProtoBody, ProtoDeclare, ProtoInstance, ProtoInterface, ROUTE, Scene, Script, Shape, Text, TouchSensor, WorldInfo, X3D, accessType and type, XML data types, field types

Event Graph ROUTE Table entries with 7 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.

ClickTextSensor
TouchSensor
isActive
SFBool

ROUTE
event to
(1)
SceneNode
ProtoInstance
evaluate
SFBool
then
 
 
 
SceneNode
ProtoInstance
currentFrameRate
SFFloat

ROUTE
event to
(2)
AssembleBrowserOutputText
Script
currentFrameRate
SFFloat
then
 
 
 
AssembleBrowserOutputText
Script
evaluatedResult
MFString

ROUTE
event to
(3)
Output3dText
Text
string
MFString
  then
 
 
 
SceneNode
ProtoInstance
currentSpeed
SFFloat

ROUTE
event to
(2)
AssembleBrowserOutputText
Script
currentSpeed
SFFloat
then
 
 
 
AssembleBrowserOutputText
Script
evaluatedResult
MFString

ROUTE
event to
(3)
Output3dText
Text
string
MFString
  then
 
 
 
SceneNode
ProtoInstance
name
SFString

ROUTE
event to
(2)
AssembleBrowserOutputText
Script
name
SFString
then
 
 
 
AssembleBrowserOutputText
Script
evaluatedResult
MFString

ROUTE
event to
(3)
Output3dText
Text
string
MFString
  then
 
 
 
SceneNode
ProtoInstance
version
SFString

ROUTE
event to
(2)
AssembleBrowserOutputText
Script
version
SFString
then
 
 
 
AssembleBrowserOutputText
Script
evaluatedResult
MFString

ROUTE
event to
(3)
Output3dText
Text
string
MFString
  then
 
 
 
SceneNode
ProtoInstance
worldUrl
SFString

ROUTE
event to
(2)
AssembleBrowserOutputText
Script
worldUrl
SFString
then
 
 
 
AssembleBrowserOutputText
Script
evaluatedResult
MFString

ROUTE
event to
(3)
Output3dText
Text
string
MFString

      AssembleBrowserOutputText
Script
evaluatedResult
MFString

ROUTE
event to
(1)
Output3dText
Text
string
MFString

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/SceneNodePrototypeIndex.html -->
<!-- Version control at
https://sourceforge.net/p/x3d/code/HEAD/tree/www.web3d.org/x3d/content/examples/Basic/development/SceneNodePrototype.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)
    <ProtoInstance name='ProtoName'> <field name='fieldName'/> </ProtoInstance> -->

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