| 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='https://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, emulating X3D4 capabilities. Assumes correct loading of resources and provides output events based on timeOut delay. This design eventually led to adoption of LoadSensor in X3D 4.0 Architecture.'/> |
| 7 | <meta name='created' content='26 December 2003'/> |
| 8 | <meta name='modified' content='7 September 2026'/> |
| 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='specificationSection' content='X3D 4.01 draft Architecture, ISO/IEC 19775-1:202x, clause 9 Networking component, 9.4.4 LoadSensor'/> |
| 13 | <meta name='specificationUrl' content='https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4.1-CD/Part01/components/networking.html#LoadSensor'/> |
| 14 | <meta name='reference' content=' LoadSensorExample.x3d '/> |
| 15 | <meta name='reference' content=' LoadSensorPrototypeInitializationTrace.txt '/> |
| 16 | <meta name='identifier' content=' https://www.web3d.org/x3d/content/examples/Basic/development/LoadSensorPrototype.x3d '/> |
| 17 | <meta name='generator' content='X3D-Edit 4.0, https://www.web3d.org/x3d/tools/X3D-Edit'/> |
| 18 | <meta name='license' content='../license.html'/> |
| 19 | </head> |
Event Graph ROUTE Table shows event connections.
-->
<!--
DEF nodes index:
Clock,
LoadSensorScript
Index for ProtoDeclare definition: LoadSensor
| 20 | <Scene> |
| 21 | <WorldInfo title='LoadSensorPrototype.x3d'/> |
| 22 | <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'> |
| 23 | <ProtoInterface> |
| 24 | <field name='enabled' type='SFBool' value='true' accessType='inputOutput' appinfo='Enables/disables the sensor node.'/> |
| 25 | <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.'/> |
| 26 | <field name='watchList' type='MFNode' accessType='initializeOnly' appinfo='Zero or more nodes with url fields to monitor.'/> |
| 27 | <field name='set_watchList' type='MFNode' accessType='inputOnly' appinfo='Change watchList MFNode array.'/> |
| 28 | <field name='isActive' type='SFBool' accessType='outputOnly' appinfo='isActive=true when loading begins isActive=false when loading ends.'/> |
| 29 | <field name='isLoaded' type='SFBool' accessType='outputOnly' appinfo='isLoaded=true when loading succeeds isLoaded=false when loading fails or timeOut reached.'/> |
| 30 | <field name='loadTime' type='SFTime' accessType='outputOnly' appinfo='loadTime event is generated when loading has successfully completed.'/> |
| 31 | <field name='progress' type='SFFloat' accessType='outputOnly' appinfo='progress [0..1] indicates fraction of loading complete.'/> |
| 32 | <field name='metadata' type='SFNode' accessType='initializeOnly' appinfo='associated Metadata node.'/> |
| 33 | </ProtoInterface> |
| 34 | <ProtoBody> |
| 35 | <Group> |
| 36 |
<!-- 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' cycleInterval='1.0' enabled='true'> |
| 37 | <IS> |
| 38 | <connect nodeField='enabled' protoField='enabled'/> |
| 39 | <connect nodeField='cycleInterval' protoField='timeOut'/> |
| 40 | </IS> |
| 41 | </TimeSensor> |
| 42 |
<!-- 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'> |
| 43 | <field name='ClockNode' type='SFNode' accessType='initializeOnly'> |
| 44 | <TimeSensor USE='Clock'/> |
| 45 | </field> |
| 46 | <field name='loopStart' type='SFTime' accessType='outputOnly'/> |
| 47 | <field name='fraction' type='SFFloat' accessType='inputOnly'/> |
| 48 | <field name='priorFraction' type='SFFloat' value='0' accessType='initializeOnly'/> |
| 49 | <field name='progress' type='SFFloat' accessType='outputOnly'/> |
| 50 | <field name='watchList' type='MFNode' accessType='initializeOnly'/> |
| 51 | <field name='set_watchList' type='MFNode' accessType='inputOnly'/> |
| 52 | <field name='isActive' type='SFBool' accessType='outputOnly'/> |
| 53 | <field name='isLoaded' type='SFBool' accessType='outputOnly'/> |
| 54 | <field name='loadTime' type='SFTime' accessType='outputOnly'/> |
| 55 | <field name='traceEnabled' type='SFBool' value='false' accessType='initializeOnly'/> |
| 56 | <IS> |
| 57 | <connect nodeField='watchList' protoField='watchList'/> |
| 58 | <connect nodeField='set_watchList' protoField='set_watchList'/> |
| 59 | <connect nodeField='isActive' protoField='isActive'/> |
| 60 | <connect nodeField='isLoaded' protoField='isLoaded'/> |
| 61 | <connect nodeField='loadTime' protoField='loadTime'/> |
| 62 | <connect nodeField='progress' protoField='progress'/> |
| 63 | </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);
}
]]>
|
|
| 65 | </Script> |
| 66 | < ROUTE fromNode='LoadSensorScript' fromField='loopStart' toNode='Clock' toField='startTime'/> |
| 67 | < ROUTE fromNode='LoadSensorScript' fromField='isActive' toNode='Clock' toField='enabled'/> |
| 68 | < ROUTE fromNode='Clock' fromField='fraction_changed' toNode='LoadSensorScript' toField='fraction'/> |
| 69 | <Collision enabled='false'> |
| 70 | <IS> |
| 71 | <connect nodeField='proxy' protoField='metadata'/> |
| 72 | </IS> |
| 73 | </Collision> |
| 74 | </Group> |
| 75 | </ProtoBody> |
| 76 | </ProtoDeclare> |
| 77 | <!-- ====================================== --> |
| 78 | <!-- Example use --> |
| 79 |
|
| 80 | <Shape> |
| 81 | <Text string='"LoadSensorPrototype" "defines a prototype" "" "Click on this text to see" "LoadSensorExample scene"'> |
| 82 | <FontStyle justify='"MIDDLE" "MIDDLE"' size='0.7'/> |
| 83 | </Text> |
| 84 | <Appearance> |
| 85 | <Material diffuseColor='1 1 0.2'/> |
| 86 | </Appearance> |
| 87 | </Shape> |
| 88 | </Anchor> |
| 89 | </Scene> |
| 90 | </X3D> |
Event Graph ROUTE Table shows event connections.
-->
<!--
DEF nodes index:
Clock,
LoadSensorScript
Index for ProtoDeclare definition: LoadSensor
🔖 Event Graph ROUTE Table entries with 3 ROUTE connections and 1 Anchor hover hint, showing X3D event-model relationships for this scene.
Each row with a ROUTE statement shows an event cascade that may occur during a single timestamp interval between frame renderings, performed as part of the X3D execution model.
|
The following
ROUTE
chain begins an event-routing loop! Loop occurs at nodeDepth=3.
ROUTE Clock.fraction_changed TO LoadSensorScript.fraction |
||||||||||
|
Clock
TimeSensor fraction_changed SFFloat |
LoadSensorScript
Script fraction SFFloat |
then from same node |
LoadSensorScript
Script isActive SFBool |
Clock
TimeSensor enabled SFBool |
then from same node |
Clock
TimeSensor fraction_changed SFFloat |
LoadSensorScript
Script fraction SFFloat |
|||
|
then from same node |
LoadSensorScript
Script loopStart SFTime |
Clock
TimeSensor startTime SFTime |
then from same node |
Clock
TimeSensor fraction_changed SFFloat |
LoadSensorScript
Script fraction SFFloat |
|||||
|
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 from same node |
Clock
TimeSensor fraction_changed SFFloat |
LoadSensorScript
Script fraction SFFloat |
then from same node |
LoadSensorScript
Script isActive SFBool |
Clock
TimeSensor enabled SFBool |
|||
|
then from same node |
LoadSensorScript
Script loopStart SFTime |
Clock
TimeSensor startTime SFTime |
||||||||
|
LoadSensorScript
Script isActive SFBool |
Clock
TimeSensor enabled SFBool |
then from same node |
Clock
TimeSensor fraction_changed SFFloat |
LoadSensorScript
Script fraction SFFloat |
then from same node |
LoadSensorScript
Script isActive SFBool |
Clock
TimeSensor enabled SFBool |
|||
|
then from same node |
LoadSensorScript
Script loopStart SFTime |
Clock
TimeSensor startTime SFTime |
||||||||
| line 79
Anchor |
description='LoadSensorExample' No direct ROUTE connection found for events to/from 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.
-->