[x3d-public] event utility usage, and event tracing techniques

Andreas Plesch andreasplesch at gmail.com
Sat Oct 29 14:21:00 PDT 2016


On Sat, Oct 29, 2016 at 2:25 PM, Don Brutzman <brutzman at nps.edu> wrote:

> On 10/29/2016 8:19 AM, Andreas Plesch wrote:
>
>> I updated
>>
>> https://rawgit.com/andreasplesch/cobweb_dom/proto/tests/inte
>> ractiveTransformations.xhtml
>>
>> to show a fade-in/out effect for the rotor handles when hovering over the
>> teapot, and decided to use event utilities rather than scripting.
>>
>
> looks great, works well!  8)
>
> It was quick to see that TimeTrigger could be used to trigger the fade
>> animation as TouchSensor does not generate a time event for just hovering.
>> It was harder for me to recognize that BooleanFilter would allow for
>> invoking the different interpolators for fading in and fading out.
>>
>
> For anyone looking to learn more: in addition to tooltips, there are also
> examples, slideset, video and quick-reference sheet on Event Utilities.
>

These are great. Since the declarative approach to animation control can be
quite unfamiliar, the examples are very important.

Here is the relevant animation section:
>>
>> <!-- fade gizmo in and out -->
>> <TimeSensor DEF='timerIn' cycleInterval='1' enabled='true' />
>> <TimeSensor DEF='timerOut' cycleInterval='1' enabled='true' />
>> <TimeTrigger DEF='getTimeIn' />
>> <TimeTrigger DEF='getTimeOut' />
>> <BooleanFilter DEF='splitBool' />
>> <ROUTE fromNode='bandsSensor' fromField='isOver' toNode='splitBool'
>> toField='set_boolean' />
>> <ROUTE fromNode='splitBool' fromField='inputTrue' toNode='getTimeIn'
>> toField='set_boolean' />
>> <ROUTE fromNode='splitBool' fromField='inputFalse' toNode='getTimeOut'
>> toField='set_boolean' />
>> <ROUTE fromNode='getTimeIn' fromField='triggerTime' toNode='timerIn'
>> toField='startTime' />
>> <ROUTE fromNode='getTimeOut' fromField='triggerTime' toNode='timerOut'
>> toField='startTime' />
>> <ScalarInterpolator DEF='fadeIn' key='0 0.5 1' keyValue='0.9 0.25 0' />
>> <ScalarInterpolator DEF='fadeOut' key='0 0.5 1' keyValue='0 0.75 0.9' />
>> <ROUTE fromNode='timerIn' fromField='fraction_changed' toNode='fadeIn'
>> toField='set_fraction' />
>> <ROUTE fromNode='timerOut' fromField='fraction_changed' toNode='fadeOut'
>> toField='set_fraction' />
>> <ROUTE fromNode='fadeIn' fromField='value_changed' toNode='RED_APP_Mat'
>> toField='transparency' />
>> <ROUTE fromNode='fadeOut' fromField='value_changed' toNode='RED_APP_Mat'
>> toField='transparency' />
>>
>>
>> It looks rather verbose and I am wondering if there is a more concise way
>> to achieve the same effect without scripting ? The answer may well be to
>> use a script.
>>
>
> Yes it can be verbose.
>

Ok. I was concerned that I missed something. For example, I first thought
it should be possible to use a single clock, and then somehow switch its
output to different interpolators. Or even use a single interpolator, and
have somehow an additional (1 - value_changed) computation for fading in.
But that means a script. Or have a single interpolator and feed it
different keyValues.
So perhaps a FloatArrayTrigger node ? Should the event utilities cover more
than Integer and Time data types ?

I have found that arranging nodes in reverse order of flow, top-to-bottom
> showing destination-to-resource, allows ROUTEs to appear immediately after
> the node where they are actionable.  If actually printing out a pretty
> print version of the scene, it lets you draw the ROUTE lines without nearly
> so much criss-crossing of the lines.  This is a helpful technique for
> animation-chain design and manual debugging.
>

Yes, I noticed that arrangement in the examples archive. With descriptive
DEF names, it is also nice to have all the ROUTEs in one place to quickly
follow where events flow.

I also learned that it can be useful to 'debug' the flow of x3d events. One
>> way is to have a script log things to the console.
>>
>
>  Are there builtin tools in x3d editors to help with tracing events
>> (perhaps as they happen) ?
>>
>
> X3D-Edit offers such a feature for X3D authors as part of many node
> editing panels.
>
>         https://savage.nps.edu/X3D-Edit/#New
>
>         "_Trace outputs_ are available for ROUTE, sensors, interpolators
> and other nodes that produce or consume events. Results are logged on the
> browser console to show the timing and values passed events. When Trace is
> selected by the author, a Script node is inserted to accomplish this task.
> This is a useful debugging technique."
>         https://savage.nps.edu/X3D-Edit/images/TraceFeatureReportsRo
> utedEventValuesOnBrowserConsoleViaScriptOutput.png
>
> This check-box feature is offered for event-producing nodes and also the
> ROUTE editor.  (TODO: need to add this feature to Script and ProtoInstance
> editing panes, iterating over fields.)
>

Something especially helpful for authors is that the trace statements are
> inserted in your debug scene.  This content-based approach lets you test
> any X3D player independently.  You can turn trace statements on/off by
> moving comments around (or simply deleting them).  Simple but effective


Excellent, good idea. I should give it a try, especially since I started to
do that manually.

I believe that some X3D development environments have offered integrated
> trace/debugging features, but am unfamiliar with any in common use.
> Certainly powerful when they work!
>
> Attached is your example with a few trace-script blocks inserted by
> X3D-Edit.  (Note that the derivative DEF names inside the added tracing
> scripts permit uniqueness.)  Once I copied/pasted/created the new scene
> with your fragment, adding the traces (i.e. selecting 4 'Trace' checkboxes)
> took about a minute.  Pretty-print html versions also generated (by button
> push) and attached for convenience.
>

Since logging all fields for all nodes becomes quickly a bit overwhelming,
it would be a nice touch to be able select in the GUI which fields are
traced (by default all).

-Andreas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20161029/39b5cae8/attachment.html>


More information about the x3d-public mailing list