KeySensor enabled field is [in out] exposedField
brutzman opened this issue · comments
KeySensor enabled field is [in out] exposedField and can be routed SFBool values.
- X3D 4.2 Architecture, clause 21 Key device sensor component, 21.4.1 KeySensor
SFBool [in,out] enabled TRUE
- https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-IS.proof/Part01/components/keyDeviceSensor.html#KeySensor
Example:
- https://www.web3d.org/x3d/content/examples/ConformanceNist/Sensors/Keyboard/KeySensorActivationKeySwitchTestIndex.html
- https://www.web3d.org/x3d/content/examples/ConformanceNist/Sensors/Keyboard/KeySensorActivationKeySwitchTest.x3d
- https://www.web3d.org/x3d/content/examples/ConformanceNist/Sensors/Keyboard/KeySensorActivationKeySwitchTest.x3dv
C:\x3d-code\www.web3d.org\x3d\content\examples\ConformanceNist/Sensors/Keyboard/KeySensorActivationKeySwitchTest.x3d processing with X3dToX3dvClassicVrmlEncoding stylesheet
ClassicVRML validation: tovrmlx3d.exe Sensors/Keyboard/KeySensorActivationKeySwitchTest.x3dv --validate --enable-downloads
tovrmlx3d: Warning: X3D: Route destination specifies field "enabled" (for node "SingleKeySensor"), but this is not an exposed field (cannot generate/receive events)
p.s. tovrmlx3d.exe
continues to provide great value, providing many edge-case tests for X3dToVrml97.xslt
conversion stylesheet. Thanks!
The KeySensor.enabled
is already exposedField ([in,out]
in X3D terms) in CGE/view3dscene. You can confirm it by checking e.g. this file
#X3D V3.0 utf8
PROFILE Immersive
DEF K KeySensor { }
DEF L PointLight { }
ROUTE L.on TO K.enabled
The problem in https://www.web3d.org/x3d/content/examples/ConformanceNist/Sensors/Keyboard/KeySensorActivationKeySwitchTestIndex.html testcase is that it defines a prototype called KeySensor
(thus obscuring internal implementation) and that prototype starts with
PROTO KeySensor [
# warning: enabled needs to become an exposedField once Scripts support exposedField
initializeOnly SFBool enabled TRUE
inputOnly SFBool set_enabled
outputOnly SFBool enabled_changed
outputOnly SFBool isActive
outputOnly SFInt32 keyPress
outputOnly SFInt32 keyRelease
outputOnly SFInt32 actionKeyPress
outputOnly SFInt32 actionKeyRelease
outputOnly SFBool altKey
outputOnly SFBool controlKey
outputOnly SFBool shiftKey
] {
As you see, the author of it even mentioned this problem at start, by that "warning:" comment.
The prototype isn't very useful -- it doesn't actually implement the node using JavaScript.
For X3D, that has KeySensor
built-in, just remove this prototype. It only makes sense in VRML 2.0 (97).
- It is contrary to intentions (declares
enabled
asinitializeOnly
), - it doesn't really do anything (it doesn't actually implement node using JavaScript),
- it is not necessary since X3D >= 3.0 just has this node in spec.