X3D Model Documentation: LoadSensorPrototype.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='LoadSensorPrototype.x3d'/>
  6            <meta name='descriptioncontent='LoadSensor prototype for VRML 97 use. Assumes correct loading of resources and provides output events based on timeOut delay.'/>
  7            <meta name='createdcontent='26 December 2003'/>
  8            <meta name='modifiedcontent='20 October 2019'/>
  9            <meta name='creatorcontent='Don Brutzman'/>
 10            <meta name='hintcontent='Set LoadSensorScript traceEnabled true/false to enable/disable console trace text.'/>
 11            <meta name=' warning content=' This LoadSensor implementation for VRML 97 only emulates LoadSensor events and cannot sense actual loading of watchList resources. Use an X3D-compliant browser for complete LoadSensor capability. '/>
 12            <meta name='referencecontent='LoadSensorExample.x3d'/>
 13            <meta name='referencecontent='LoadSensorPrototypeInitializationTrace.txt'/>
 14            <meta name='identifiercontent='https://www.web3d.org/x3d/content/examples/Basic/development/LoadSensorPrototype.x3d'/>
 15            <meta name='generatorcontent='X3D-Edit 3.3, https://savage.nps.edu/X3D-Edit'/>
 16            <meta name='licensecontent='../license.html'/>
 17       </head>
<!--

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

<!-- to top Index for DEF nodes: Clock, LoadSensorScript

Index for ProtoDeclare definition: LoadSensor
-->
 18       <Scene>
 19            <WorldInfo title='LoadSensorPrototype.x3d'/>
 20            <ProtoDeclare name='LoadSensorappinfo='LoadSensor monitors the progress and success of downloading URL elements over a network. Only nodes that contain a valid URL field (i.e. descendants of X3DUrlObject) may be specified as watchList children. Multiple nodes may be watched with a single LoadSensor.' documentation='https://www.web3d.org/specifications/ISO-IEC-19775/Part01/components/networking.html#LoadSensor'>
 21                 <ProtoInterface>
 22                      <field name='enabledtype='SFBoolvalue='trueaccessType='inputOutput'
                     appinfo='Enables/disables the sensor node.'/>
 23                      <field name='timeOuttype='SFTimevalue='0accessType='inputOutput'
                     appinfo='Maximum time for which the LoadSensor will monitor loading starting from when the sensor becomes active. timeOut=0 ordinarily indicates an indefinite time out period; i.e. the LoadSensor will wait until loading has completed either with success or failure timeOut=0 causes immediate loading for this implementation.'/>
 24                      <field name='watchListtype='MFNodeaccessType='initializeOnly'
                     appinfo='Zero or more nodes with url fields to monitor.'/>
 25                      <field name='set_watchListtype='MFNodeaccessType='inputOnly'
                     appinfo='Change watchList MFNode array.'/>
 26                      <field name='isActivetype='SFBoolaccessType='outputOnly'
                     appinfo='isActive=true when loading begins isActive=false when loading ends.'/>
 27                      <field name='isLoadedtype='SFBoolaccessType='outputOnly'
                     appinfo='isLoaded=true when loading succeeds isLoaded=false when loading fails or timeOut reached.'/>
 28                      <field name='loadTimetype='SFTimeaccessType='outputOnly'
                     appinfo='loadTime event is generated when loading has successfully completed.'/>
 29                      <field name='progresstype='SFFloataccessType='outputOnly'
                     appinfo='progress [0..1] indicates fraction of loading complete.'/>
 30                      <field name='metadatatype='SFNodeaccessType='initializeOnly'
                     appinfo='associated Metadata node.'/>
 31                 </ProtoInterface>
 32                 <ProtoBody>
 33                      <Group>
 34 
                         <!-- TimeSensor Clock is a DEF node that has 1 USE node: USE_1
                         <!-- ROUTE information for Clock node:  [from LoadSensorScript.loopStart to startTime ] [from LoadSensorScript.isActive to enabled ] [from fraction_changed to LoadSensorScript.fraction ] -->
                         <TimeSensor DEF='Clockloop='true'>
 35                                <IS>
 36                                     <connect nodeField='enabledprotoField='enabled'/>
 37                                     <connect nodeField='cycleIntervalprotoField='timeOut'/>
 38                                </IS>
 39                           </TimeSensor>
 40 
                         <!-- ROUTE information for LoadSensorScript node:  [from Clock.fraction_changed to fraction ] [from loopStart to Clock.startTime ] [from isActive to Clock.enabled ] -->
                         <Script DEF='LoadSensorScriptdirectOutput='true'>
 41                                <field name='ClockNodetype='SFNodeaccessType='initializeOnly'>
 42                                     <TimeSensor USE='Clock'/>
 43                                </field>
 44                                <field name='loopStarttype='SFTimeaccessType='outputOnly'/>
 45                                <field name='fractiontype='SFFloataccessType='inputOnly'/>
 46                                <field name='priorFractiontype='SFFloatvalue='0accessType='initializeOnly'/>
 47                                <field name='progresstype='SFFloataccessType='outputOnly'/>
 48                                <field name='watchListtype='MFNodeaccessType='initializeOnly'/>
 49                                <field name='set_watchListtype='MFNodeaccessType='inputOnly'/>
 50                                <field name='isActivetype='SFBoolaccessType='outputOnly'/>
 51                                <field name='isLoadedtype='SFBoolaccessType='outputOnly'/>
 52                                <field name='loadTimetype='SFTimeaccessType='outputOnly'/>
 53                                <field name='traceEnabledtype='SFBoolvalue='falseaccessType='initializeOnly'/>
 54                                <IS>
 55                                     <connect nodeField='watchListprotoField='watchList'/>
 56                                     <connect nodeField='set_watchListprotoField='set_watchList'/>
 57                                     <connect nodeField='isActiveprotoField='isActive'/>
 58                                     <connect nodeField='isLoadedprotoField='isLoaded'/>
 59                                     <connect nodeField='loadTimeprotoField='loadTime'/>
 60                                     <connect nodeField='progressprotoField='progress'/>
 61                                </IS>
  <![CDATA[
            
ecmascript:

function initialize ()
{
	enabled = ClockNode.enabled;
	tracePrint ('initialize() enabled=' + enabled);
	if (enabled)
	{
		isActive = true;
		// isLoaded event only sent upon completion
		progress = 0.0;
		tracePrintEvents ();
		timeOut = ClockNode.cycleInterval;
		tracePrint ('timeOut=' + timeOut);
		if (timeOut <= 0.0) // instantaneous, no loop
		{
			isActive = false;
			isLoaded = true;
			progress = 1.0;
			loadTime = timestamp;
			tracePrintEvents ();
		}
	}
}
function fraction (value, timestamp)
{
	enabled = ClockNode.enabled;
	if (enabled)
		tracePrint ('progress=' + value + ', priorFraction=' + priorFraction);
	// use priorFraction to check for looping, then stop loop
	if (enabled && ((value >=1) || (value < priorFraction)))
	{
		isActive = false;
		isLoaded = true;
		loadTime = timestamp;
		progress = 1;
		tracePrintEvents ();
		tracePrint ('complete');
                loopStart = true;
	}
	else progress= value; // output event
	priorFraction = progress;
}
function set_watchList (value, timestamp)
{
	watchList = value;
}
function tracePrintEvents ()
{
	tracePrint ('isActive=' + isActive);
	tracePrint ('isLoaded=' + isLoaded);
	tracePrint ('loadTime=' + loadTime);
	tracePrint ('progress=' + progress);
}
function tracePrint (outputString)
{
	if (traceEnabled) Browser.println ('[LoadSensor]' + outputString);
}
function alwaysPrint (outputString)
{
	Browser.println ('[LoadSensor]' + outputString);
}

          
]]>
 63                           </Script>
 64                           < ROUTE  fromNode='LoadSensorScript' fromField='loopStart' toNode='Clock' toField='startTime'/>
 65                           < ROUTE  fromNode='LoadSensorScript' fromField='isActive' toNode='Clock' toField='enabled'/>
 66                           < ROUTE  fromNode='Clock' fromField='fraction_changed' toNode='LoadSensorScript' toField='fraction'/>
 67                           <Collision enabled='false'>
 68                                <IS>
 69                                     <connect nodeField='proxyprotoField='metadata'/>
 70                                </IS>
 71                           </Collision>
 72                      </Group>
 73                 </ProtoBody>
 74            </ProtoDeclare>
 75            <!-- ====================================== -->
 76            <!-- Example use -->
 77            <Anchor description='LoadSensorExampleparameter='"target=_blank"'   url=' "LoadSensorExample.x3d" "https://www.web3d.org/x3d/content/examples/Basic/development/LoadSensorExample.x3d" "LoadSensorExample.wrl" "https://www.web3d.org/x3d/content/examples/Basic/development/LoadSensorExample.wrl" '>
 78                 <Shape>
 79                      <Text string='"LoadSensorPrototype" "defines a prototype" "" "Click on this text to see" "LoadSensorExample scene"'>
 80                           <FontStyle justify='"MIDDLE" "MIDDLE"size='0.7'/>
 81                      </Text>
 82                      <Appearance>
 83                           <Material diffuseColor='1 1 0.2'/>
 84                      </Appearance>
 85                 </Shape>
 86            </Anchor>
 87       </Scene>
 88  </X3D>
<!--

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

<!-- to top Index for DEF nodes: Clock, LoadSensorScript

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

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

     
The following ROUTE chain begins an event-routing loop! Loop occurs at nodeDepth=3.
 
ROUTE LoadSensorScript.loopStart TO Clock.startTime
LoadSensorScript
Script
loopStart
SFTime

ROUTE
event to
(1)
Clock
TimeSensor
startTime
SFTime
then
 
 
 
Clock
TimeSensor
fraction_changed
SFFloat

ROUTE
event to
(2)
LoadSensorScript
Script
fraction
SFFloat
then
 
 
 
LoadSensorScript
Script
isActive
SFBool

ROUTE
event to
(3)
Clock
TimeSensor
enabled
SFBool
  then
 
 
 
LoadSensorScript
Script
loopStart
SFTime

ROUTE
event to
(3)
Clock
TimeSensor
startTime
SFTime
LoadSensorScript
Script
isActive
SFBool

ROUTE
event to
(1)
Clock
TimeSensor
enabled
SFBool
then
 
 
 
Clock
TimeSensor
fraction_changed
SFFloat

ROUTE
event to
(2)
LoadSensorScript
Script
fraction
SFFloat
then
 
 
 
LoadSensorScript
Script
isActive
SFBool

ROUTE
event to
(3)
Clock
TimeSensor
enabled
SFBool
  then
 
 
 
LoadSensorScript
Script
loopStart
SFTime

ROUTE
event to
(3)
Clock
TimeSensor
startTime
SFTime


Anchor
description='LoadSensorExample' 
User-interaction hint for this node. 
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/LoadSensorPrototypeIndex.html -->
<!-- Version control at
https://sourceforge.net/p/x3d/code/HEAD/tree/www.web3d.org/x3d/content/examples/Basic/development/LoadSensorPrototype.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. -->