| 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='title' content=' LoadSensorPrototype.x3d '/> |
| 6 | <meta name='description' content='LoadSensor prototype for VRML 97 use. Assumes correct loading of resources and provides output events based on timeOut delay.'/> |
| 7 | <meta name='created' content='26 December 2003'/> |
| 8 | <meta name='modified' content='20 October 2019'/> |
| 9 | <meta name='creator' content='Don Brutzman'/> |
| 10 | <meta name='hint' content='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='reference' content=' LoadSensorExample.x3d '/> |
| 13 | <meta name='reference' content=' LoadSensorPrototypeInitializationTrace.txt '/> |
| 14 | <meta name='identifier' content=' https://www.web3d.org/x3d/content/examples/Basic/development/LoadSensorPrototype.x3d '/> |
| 15 | <meta name='generator' content='X3D-Edit 3.3, https://www.web3d.org/x3d/tools/X3D-Edit'/> |
| 16 | <meta name='license' content='../license.html'/> |
| 17 | </head> |
| 18 | <Scene> |
| 19 | <WorldInfo title='LoadSensorPrototype.x3d'/> |
| 20 | <ProtoDeclare name='LoadSensor' appinfo='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='enabled' type='SFBool' value='true' accessType='inputOutput'
appinfo='Enables/disables the sensor node.'/> |
| 23 |
<field name='timeOut' type='SFTime' value='0' accessType='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='watchList' type='MFNode' accessType='initializeOnly'
appinfo='Zero or more nodes with url fields to monitor.'/> |
| 25 |
<field name='set_watchList' type='MFNode' accessType='inputOnly'
appinfo='Change watchList MFNode array.'/> |
| 26 |
<field name='isActive' type='SFBool' accessType='outputOnly'
appinfo='isActive=true when loading begins isActive=false when loading ends.'/> |
| 27 |
<field name='isLoaded' type='SFBool' accessType='outputOnly'
appinfo='isLoaded=true when loading succeeds isLoaded=false when loading fails or timeOut reached.'/> |
| 28 |
<field name='loadTime' type='SFTime' accessType='outputOnly'
appinfo='loadTime event is generated when loading has successfully completed.'/> |
| 29 |
<field name='progress' type='SFFloat' accessType='outputOnly'
appinfo='progress [0..1] indicates fraction of loading complete.'/> |
| 30 |
<field name='metadata' type='SFNode' accessType='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='Clock' loop='true'> |
| 35 | <IS> |
| 36 | <connect nodeField='enabled' protoField='enabled'/> |
| 37 | <connect nodeField='cycleInterval' protoField='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='LoadSensorScript' directOutput='true'> |
| 41 | <field name='ClockNode' type='SFNode' accessType='initializeOnly'> |
| 42 | <TimeSensor USE='Clock'/> |
| 43 | </field> |
| 44 | <field name='loopStart' type='SFTime' accessType='outputOnly'/> |
| 45 | <field name='fraction' type='SFFloat' accessType='inputOnly'/> |
| 46 | <field name='priorFraction' type='SFFloat' value='0' accessType='initializeOnly'/> |
| 47 | <field name='progress' type='SFFloat' accessType='outputOnly'/> |
| 48 | <field name='watchList' type='MFNode' accessType='initializeOnly'/> |
| 49 | <field name='set_watchList' type='MFNode' accessType='inputOnly'/> |
| 50 | <field name='isActive' type='SFBool' accessType='outputOnly'/> |
| 51 | <field name='isLoaded' type='SFBool' accessType='outputOnly'/> |
| 52 | <field name='loadTime' type='SFTime' accessType='outputOnly'/> |
| 53 | <field name='traceEnabled' type='SFBool' value='false' accessType='initializeOnly'/> |
| 54 | <IS> |
| 55 | <connect nodeField='watchList' protoField='watchList'/> |
| 56 | <connect nodeField='set_watchList' protoField='set_watchList'/> |
| 57 | <connect nodeField='isActive' protoField='isActive'/> |
| 58 | <connect nodeField='isLoaded' protoField='isLoaded'/> |
| 59 | <connect nodeField='loadTime' protoField='loadTime'/> |
| 60 | <connect nodeField='progress' protoField='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='proxy' protoField='metadata'/> |
| 70 | </IS> |
| 71 | </Collision> |
| 72 | </Group> |
| 73 | </ProtoBody> |
| 74 | </ProtoDeclare> |
| 75 | <!-- ====================================== --> |
| 76 | <!-- Example use --> |
| 77 | <Anchor description='LoadSensorExample' parameter='"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 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 |
Clock
TimeSensor startTime SFTime |
then
|
Clock
TimeSensor fraction_changed SFFloat |
LoadSensorScript
Script fraction SFFloat |
then
|
LoadSensorScript
Script isActive SFBool |
Clock
TimeSensor enabled SFBool |
|||
|
then
|
LoadSensorScript
Script loopStart SFTime |
Clock
TimeSensor startTime SFTime |
||||||||
|
LoadSensorScript
Script isActive SFBool |
Clock
TimeSensor enabled SFBool |
then
|
Clock
TimeSensor fraction_changed SFFloat |
LoadSensorScript
Script fraction SFFloat |
then
|
LoadSensorScript
Script isActive SFBool |
Clock
TimeSensor enabled SFBool |
|||
|
then
|
LoadSensorScript
Script loopStart SFTime |
Clock
TimeSensor startTime SFTime |
||||||||
| line 77
Anchor |
description='LoadSensorExample' User-interaction hint for this node. |
<!--
Color-coding 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>
-->
<!--
For additional help information about X3D scenes, please see X3D Tooltips, X3D Resources, and X3D Scene Authoring Hints.
-->