Difference between revisions of "Script-and-inputOutputField.x3d"
From Web3D.org
(Using inputOuput Fields in scripts) |
|||
Line 1: | Line 1: | ||
− | + | <?xml version="1.0" encoding="UTF-8"?> | |
− | + | <X3D profile='Full' > | |
− | + | ||
<Scene DEF='scene'> | <Scene DEF='scene'> | ||
<Viewpoint position='20 0 40'/> | <Viewpoint position='20 0 40'/> | ||
Line 13: | Line 12: | ||
<field accessType='inputOutput' name='foo' type='SFFloat' value='5'/> | <field accessType='inputOutput' name='foo' type='SFFloat' value='5'/> | ||
<field accessType='inputOnly' name='readFoo' type='SFTime'/><![CDATA[ecmascript: | <field accessType='inputOnly' name='readFoo' type='SFTime'/><![CDATA[ecmascript: | ||
+ | |||
//----------------------------- | //----------------------------- | ||
function initialize (value) { | function initialize (value) { | ||
Line 18: | Line 18: | ||
text.string[0] = line; | text.string[0] = line; | ||
} | } | ||
+ | |||
//----------------------------- | //----------------------------- | ||
function readFoo (value) { | function readFoo (value) { | ||
text.string[1] = 'readFoo called: TRUE, value: ' + foo; | text.string[1] = 'readFoo called: TRUE, value: ' + foo; | ||
} | } | ||
+ | |||
//----------------------------- | //----------------------------- | ||
function foo (value) { | function foo (value) { | ||
text.string[3] = 'foo function called: TRUE; ' + value; | text.string[3] = 'foo function called: TRUE; ' + value; | ||
} | } | ||
+ | |||
//----------------------------- | //----------------------------- | ||
function set_foo (value) { | function set_foo (value) { | ||
text.string[4] = 'set_foo function called: TRUE; ' + value; | text.string[4] = 'set_foo function called: TRUE; ' + value; | ||
} | } | ||
+ | |||
//----------------------------- | //----------------------------- | ||
function foo_changed (value) { | function foo_changed (value) { | ||
Line 42: | Line 46: | ||
</field> | </field> | ||
<field accessType='inputOnly' name='fooCatcher' type='SFFloat'/><![CDATA[ecmascript: | <field accessType='inputOnly' name='fooCatcher' type='SFFloat'/><![CDATA[ecmascript: | ||
+ | |||
//----------------------- | //----------------------- | ||
function fooCatcher (value) { | function fooCatcher (value) { | ||
text.string[2] = 'Foo value send: TRUE; value: ' + value; | text.string[2] = 'Foo value send: TRUE; value: ' + value; | ||
} | } | ||
+ | |||
]]> | ]]> | ||
</Script> | </Script> | ||
Line 52: | Line 58: | ||
<ROUTE fromNode='s1' fromField='foo_changed' toNode='s2' toField='fooCatcher'/> | <ROUTE fromNode='s1' fromField='foo_changed' toNode='s2' toField='fooCatcher'/> | ||
</Scene> | </Scene> | ||
− | + | </X3D> | |
+ | |||
+ | == Browser Results == | ||
+ | {| class="wikitable" border="1" | ||
+ | |- | ||
+ | ! Browser | ||
+ | ! Version | ||
+ | ! Result | ||
+ | ! Notes | ||
+ | |- | ||
+ | | BS Contact | ||
+ | | 7.107 | ||
+ | | Not Expected | ||
+ | | No objects showing, global not supported | ||
+ | |- | ||
+ | | FreeWRL | ||
+ | | | ||
+ | | Untested | ||
+ | | | ||
+ | |||
+ | |- | ||
+ | | Octaga | ||
+ | | 2.2.0.12 | ||
+ | | Expected | ||
+ | | | ||
+ | |- | ||
+ | | Instant Reality | ||
+ | | 2.0.0_beta4 | ||
+ | | Not Expected | ||
+ | | Both spheres the same intensity, expect attenuation not supported | ||
+ | | | ||
+ | |- | ||
+ | | Vivaty | ||
+ | | 2.1 | ||
+ | | Expected | ||
+ | | | ||
+ | |- | ||
+ | | Xj3D | ||
+ | | 2_M1_DEV_2008-06_02 | ||
+ | | Expected | ||
+ | | | ||
+ | |} |
Revision as of 21:08, 6 August 2008
<?xml version="1.0" encoding="UTF-8"?> <X3D profile='Full' >
<Scene DEF='scene'> <Viewpoint position='20 0 40'/> <Shape> <Text DEF='text' string='"Initialize called: FALSE" "readFoo() called: FALSE" "foo value send: FALSE" "foo function called: FALSE" "set_foo function called: FALSE" "foo_changed function called: FALSE"'/> </Shape> <Script DEF='s1' directOutput='true'> <field accessType='initializeOnly' name='text' type='SFNode'> <Text USE='text'/> </field> <field accessType='inputOutput' name='foo' type='SFFloat' value='5'/> <field accessType='inputOnly' name='readFoo' type='SFTime'/><![CDATA[ecmascript:
//----------------------------- function initialize (value) { line = 'Initialized called: TRUE; foo value: ' + foo; text.string[0] = line; }
//----------------------------- function readFoo (value) { text.string[1] = 'readFoo called: TRUE, value: ' + foo; }
//----------------------------- function foo (value) { text.string[3] = 'foo function called: TRUE; ' + value; }
//----------------------------- function set_foo (value) { text.string[4] = 'set_foo function called: TRUE; ' + value; }
//----------------------------- function foo_changed (value) { text.string[5] = 'foo_changed function called: TRUE; ' + value; } ]]> </Script> <TimeSensor DEF='ts' cycleInterval='3' loop='true'/> <Script DEF='s2' directOutput='true'> <field accessType='initializeOnly' name='text' type='SFNode'> <Text USE='text'/> </field> <field accessType='inputOnly' name='fooCatcher' type='SFFloat'/><![CDATA[ecmascript:
//----------------------- function fooCatcher (value) { text.string[2] = 'Foo value send: TRUE; value: ' + value; }
]]> </Script> <ROUTE fromNode='ts' fromField='fraction_changed' toNode='s1' toField='set_foo'/> <ROUTE fromNode='ts' fromField='cycleTime' toNode='s1' toField='readFoo'/> <ROUTE fromNode='s1' fromField='foo_changed' toNode='s2' toField='fooCatcher'/> </Scene>
</X3D>
Browser Results
Browser | Version | Result | Notes | |
---|---|---|---|---|
BS Contact | 7.107 | Not Expected | No objects showing, global not supported | |
FreeWRL | Untested | |||
Octaga | 2.2.0.12 | Expected | ||
Instant Reality | 2.0.0_beta4 | Not Expected | Both spheres the same intensity, expect attenuation not supported | |
Vivaty | 2.1 | Expected | ||
Xj3D | 2_M1_DEV_2008-06_02 | Expected |