[x3d-public] dynamic cycleInterval changes

Andreas Plesch andreasplesch at gmail.com
Sun Nov 20 12:36:40 PST 2016


I want to change the cycleTime of a TimeSensor in a x3d script:

https://raw.githubusercontent.com/andreasplesch/cobweb_dom/master/tests/dynamicCycleTime.x3d

cycleTime input events are ignored when the TimeSensor is enabled. So it is
necessary to disable it first, then change the cycleTime and then reenable
it.

However, in all tested browser the above does not work as expected. These
are cobweb, instant player and bs contact. bs contact also has this console
message:
Script node speeder: parse error: line 16 "time.cycleInterval = 2;" ()
and therefore does not get to change the color to grey.
The javascript sai does not have a SFTime constructor and allows numbers.

cobweb and instant player change the color but do not slow down the ball.
I first thought that cobweb does not correctly work through the sequence of
events but since no browser works sofar I start to think that I am missing
something.

Any help or feedback appreciated,

-Andreas

On Sat, Nov 19, 2016 at 8:39 PM, Andreas Plesch <andreasplesch at gmail.com>
wrote:

> Hi Roy,
>
> Here is a cobweb version of the updated example:
>
> https://rawgit.com/andreasplesch/cobweb_dom/master/tests/html5/cobweb_
> integration2.html
>
> I removed all features which are only supported by or necessary for the
> x3dom version.
>
> The main necessary changes were:
>
> - use setAttribute on DOM elements rather than DOM element properties
> because cobweb does not create these properties. x3dom allows for using
> setAttribute() in addition to setting properties.
>
> - use a TouchSensor node to enable clicking on the ball instead of the
> onclick attribute. Cobweb ignores the onclick attribute and x3dom ignores
> the touch sensor. In Cobweb the TouchSensor generates and is the target of
> a dom event ('x3d_touchTime') which can be received by an installed
> listener. The .addEventListener() call does this.
>
> - modify the scale attribute of the enclosing transform instead of the
> radius attribute of the sphere since radius is not recognized as an input
> field in Cobweb as it interprets the spec. this way.
> I also looked more closely into why I had to introduce a timeout delay to
> make the TimeSensor cycleInterval change have an effect. It turns that
> there were multiple reasons. Interestingly, the first reason had to do with
> how the DOM spec. defines Mutation Observers and I filed a spec. issue:
> https://github.com/whatwg/dom/issues/376
> In effect, the enabled='false' mutation was not reported fully. I could
> fix this in cobweb_dom, so it was a worthy investigation.
> Also interestingly, the second reason had to with how cobweb processes
> input events. From what I understand first fields get tainted and are then
> processed in the cascade. I think the second set_enabled event occurred
> before the first had a chance to be processed and reset the target value
> back. This was also possible to fix in cobweb_dom by forcing processing
> after each mutation (input event).
>
> As a result, the delay is not necessary anymore and the sequence works as
> expected.
>
> -Andreas
>
> On Sat, Nov 12, 2016 at 5:48 AM, Roy Walmsley <roy.walmsley at ntlworld.com>
> wrote:
>
>> Hi Andreas,
>>
>>
>>
>> Having a Cobweb version is great. Thank you very much.
>>
>>
>>
>> You’re comments are also interesting. Lots of food for thought. I will
>> modify both examples to illustrate using X3D output events as well, as I
>> have completely missed that feature. I’ll also modify the titles to include
>> the implementation, and put both on the web site.
>>
>>
>>
>> Regards,
>>
>>
>>
>> Roy
>>
>>
>>
>> *From:* Andreas Plesch [mailto:andreasplesch at gmail.com]
>> *Sent:* 12 November 2016 01:19
>> *To:* Roy Walmsley <roy.walmsley at ntlworld.com>
>> *Cc:* X3D Graphics Working Group <x3d at web3d.org>
>> *Subject:* Re: X3D / DOM integration example using X3DOM
>>
>>
>>
>> Hi Roy,
>>
>> this is a nice example, demonstrating main integration features.
>>
>> I modified it to work with cobweb_dom:
>>
>> https://rawgit.com/andreasplesch/cobweb_dom/master/tests/
>> html5/cobweb_integration.html
>>
>> This should also still work mostly unchanged with x3dom although it looks
>> perhaps quite different.
>>
>> The main necessary changes were:
>>
>> - use setAttribute on DOM elements rather than DOM element properties
>> because cobweb does not create these properties. x3dom allows for using
>> setAttribute.
>>
>> - use a TouchSensor node to enable clicking on the ball instead of the
>> onclick attribute. Cobweb ignores the onclick attribute and x3dom ignores
>> the touch sensor.
>>
>> - introduce a small delay after disabling the time sensor to make sure it
>> is actually disabled when the cycle interval is set in an input event. This
>> looks like it should not be necessary to do, so will require some
>> investigation.
>>
>> - modify the scale attribute instead of the radius attribute since radius
>> is not an input field. Cobweb follows the spec. strictly, x3dom is more
>> liberal. Radius should become an input field.
>>
>> So two questions emerge:
>>
>> Should DOM element properties be required? No, in my opinion, since
>> attributes are the more fundamental component and definitely required in
>> the XML encoding. It is probably possible to have another layer which
>> translates attributes into properties and back.
>>
>> Which x3d output events should be exposed and how ? Following x3d
>> conventions (TouchSensor) or following DOM event conventions (click) ?
>> Undecided, leaning towards x3d, perhaps both. x3dom and Cobweb expose all
>> output events, x3dom with outputchange and Cobweb with x3d_eventname.
>> (It would be probably possible to implement click and other dom event
>> dispatchers by adding sensor nodes to the scene graph but not to the dom
>> tree).
>>
>> Andreas
>>
>>
>>
>> On Fri, Nov 11, 2016 at 10:13 AM, Roy Walmsley <roy.walmsley at ntlworld.com>
>> wrote:
>>
>> Hi all,
>>
>>
>>
>> Following Wednesday’s open meeting I have put together an example that
>> illustrates the integration of an X3D scene into an HTML web page, that
>> also incorporates SVG. It includes events, both X3D and HTML. There is also
>> interaction between X3D, SVG, and HTML in multiple directions.
>>
>>
>>
>> The intention was to provide a simple (but not high quality!) example to
>> facilitate thinking about specification requirements.
>>
>>
>>
>> Sorry that I couldn’t put the example directly onto one of our web pages.
>> But it should be easy for you to copy and paste to create your own file and
>> open it up in a browser. The only browser that’s failed me so far is Safari.
>>
>>
>>
>> Here’s the link: http://www.web3d.org/member/wi
>> ki/x3d-svg-html-dom-integration-example-using-x3dom
>>
>>
>>
>> Have fun,
>>
>>
>>
>> Roy
>>
>>
>>
>> PS As it came up on Wednesday I have also added an HTML slider,
>> demonstrating instant updating.
>>
>>
>>
>>
>>
>> --
>>
>> Andreas Plesch
>> 39 Barbara Rd.
>> Waltham, MA 02453
>>
>
>
>
> --
> Andreas Plesch
> 39 Barbara Rd.
> Waltham, MA 02453
>



-- 
Andreas Plesch
39 Barbara Rd.
Waltham, MA 02453
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20161120/89971946/attachment.html>


More information about the x3d-public mailing list