<div dir="auto"><div><div class="gmail_extra"><div class="gmail_quote">On Jun 2, 2017 5:49 PM, "Leonard Daly" <<a href="mailto:Leonard.Daly@realism.com">Leonard.Daly@realism.com</a>> wrote:<br type="attribution"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  
    
  
  <div text="#000000" bgcolor="#FFFFFF">
    <div class="m_-2326937162992248327moz-cite-prefix">Andreas,<br>
      <br>
      Regarding the DOM...<br>
      <br>
      DOM defines several events (and event handlers) for some items of
      interest here. <br></div></div></blockquote></div></div></div><div dir="auto"><br></div><div dir="auto">Typically, handler refers to the callback function an event listener invokes. These are defined by dom user code.</div><div dir="auto"><br></div><div dir="auto"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div text="#000000" bgcolor="#FFFFFF"><div class="m_-2326937162992248327moz-cite-prefix"><br>
      If the structure of a document changes (meaning a DOM element is
      added or removed), the a DOM mutation callback is invoked (note
      that mutation events have been deprecated). A callback is only
      involved if one was registered for this node (and children). You
      can directly insert or remove a DOM element: there is no event or
      callback that does this. The MutationObserver callback responds to
      the change.<br></div></div></blockquote></div></div></div><div dir="auto"><br></div><div dir="auto">Ok.</div><div dir="auto"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div text="#000000" bgcolor="#FFFFFF"><div class="m_-2326937162992248327moz-cite-prefix">
      <br>
      Note that there is no MutationObserver action if a
      field/attribute/property value is changed.</div></div></blockquote></div></div></div><div dir="auto"><br></div><div dir="auto">There actually is if the MutationObserver was configured such, as John points out.</div><div dir="auto"><br></div><div dir="auto"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div text="#000000" bgcolor="#FFFFFF"><div class="m_-2326937162992248327moz-cite-prefix"> That kind of change
      does not change the structure of the DOM.<br></div></div></blockquote></div></div></div><div dir="auto"><br></div><div dir="auto">I believe attribute changes are considered mutations.</div><div dir="auto"><br></div><div dir="auto"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div text="#000000" bgcolor="#FFFFFF"><div class="m_-2326937162992248327moz-cite-prefix">
      <br>
      Since DOM events bubble (until captured or stopped),</div></div></blockquote></div></div></div><div dir="auto"><br></div><div dir="auto">Custom events can be told not to bubble.</div><div dir="auto"><br></div><div dir="auto"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div text="#000000" bgcolor="#FFFFFF"><div class="m_-2326937162992248327moz-cite-prefix"> I would be
      careful about using those to handle large quantities of data
      (e.g., CoordinateInterpolator) or things that changed frequently
      (like every animation frame). <br>
      </div></div></blockquote></div></div></div><div dir="auto"><br></div><div dir="auto">I used to think that but events are managed very efficiently these days. They get discarded very quickly (or are perhaps not even generated) when they will not have an effect, as determined by the browser.</div><div dir="auto"><br></div><div dir="auto"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div text="#000000" bgcolor="#FFFFFF"><div class="m_-2326937162992248327moz-cite-prefix"><br>
      In DOM land, scripts can directly manipulate any DOM element
      including children and properties. Using</div></div></blockquote></div></div></div><div dir="auto"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div text="#000000" bgcolor="#FFFFFF"><div class="m_-2326937162992248327moz-cite-prefix"> a little of the X3D
      terminology, all DOM scripts come with "directOutput = TRUE".</div></div></blockquote></div></div></div><div dir="auto"><br></div><div dir="auto">Ok.</div><div dir="auto"></div><div dir="auto"><br></div><div dir="auto">--</div><div dir="auto">This has implications for the concept of an event cascade (doesn't
      happen in a single timestamp). DOM events get queued up for
      execution at the next pause in script execution.</div><div dir="auto">--</div><div dir="auto"><br></div><div dir="auto">Not sure when exactly events arrive at listeners and when handlers are then invoked. Probably 'as soon as possible' . Does the DOM spec. say pause in script execution ?</div><div dir="auto"><br></div><div dir="auto">Each event has a time stamp so it should be possible to compare that time stamp with the actual (reported) time of 'now' when handler functions are executed. I see if I can add this comparison to the scene code. </div><div dir="auto"><br></div><div dir="auto">In JavaScript object land Proxys can intercept attempts at mutations (or anything else) and are probably faster than MutationObservers or event driven chains.</div><div dir="auto"><br></div><div dir="auto">Andreas</div><div dir="auto"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div text="#000000" bgcolor="#FFFFFF"><div class="m_-2326937162992248327moz-cite-prefix">
      <br>
      <br>
      Leonard Daly<br>
      <br>
      <br>
      <br>
      <br>
    </div>
    <blockquote type="cite"><div class="elided-text">
      <div dir="ltr">
        <div class="gmail_extra">
          <div class="gmail_quote">On Fri, Jun 2, 2017 at 3:19 PM,
            Andreas Plesch <span dir="ltr"><<a href="mailto:andreasplesch@gmail.com" target="_blank">andreasplesch@gmail.com</a>></span>
            wrote:<br>
            <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
              <div dir="ltr">
                <div>... Is there a conformance example ?</div>
                <div><br>
                </div>
              </div>
            </blockquote>
            <div><br>
            </div>
            <div>There is one which uses directOut:</div>
            <div><br>
            </div>
            <div><a href="http://www.web3d.org/x3d/content/examples/ConformanceNist/Miscellaneous/Script/ScriptNodeFieldControl_EcmaScriptIndex.html" target="_blank">http://www.web3d.org/x3d/<wbr>content/examples/<wbr>ConformanceNist/Miscellaneous/<wbr>Script/ScriptNodeFieldControl_<wbr>EcmaScriptIndex.html</a><br>
            </div>
            <div> </div>
            <div>But it does not test event generation and cascading as
              far as I can see. Also, cobweb does not seem to work with
              it indicating issues somewhere.</div>
            <div><br>
            </div>
            <div>-Andreas</div>
            <div><br>
            </div>
            <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
              <div dir="ltr">
                <div><br>
                </div>
                <div>
                  <div class="gmail_extra"><br>
                    <div class="gmail_quote">On Fri, Jun 2, 2017 at
                      11:34 AM, Joe D Williams <span dir="ltr"><<a href="mailto:joedwil@earthlink.net" target="_blank">joedwil@earthlink.net</a>></span>
                      wrote:<br>
                      <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Yes, the
                        script that uses directOut is like a DOM script.<br>
                        Operationally, I think it is important to
                        recognize that the directOut in x3d was designed
                        to not produce an event directly. The x3d event
                        is produced when the target node field is
                        changed. In other worls, see that you cannot
                        route an event from the directOut. The changed
                        event must be generated by watching the target
                        field of the node used by the directOut.<br>
                        <br>
                        Joe<br>
                        <br>
                        <br>
                        <br>
                        riginal Message ----- From: "Andreas Plesch"
                        <<a href="mailto:andreasplesch@gmail.com" target="_blank">andreasplesch@gmail.com</a>><br>
                        To: "John Carlson" <<a href="mailto:yottzumm@gmail.com" target="_blank">yottzumm@gmail.com</a>><br>
                        Cc: "x3dom mlist" <<a href="mailto:x3dom-users@lists.sourceforge.net" target="_blank">x3dom-users@lists.sourceforge<wbr>.net</a>>;
                        "X3D Graphics public mailing list" <<a href="mailto:x3d-public@web3d.org" target="_blank">x3d-public@web3d.org</a>><br>
                        Sent: Friday, June 02, 2017 8:11 AM<br>
                        Subject: Re: [x3d-public] [x3dom-users] port
                        this example to X3DOM?<br>
                        <br>
                        <br>
                        <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
                          John,<br>
                          <br>
                          I realized that the ported script uses what is
                          equivalent to the<br>
                          directOutput style of x3d scripts. This means
                          that it may be possible to<br>
                          convert directOutput scripts to x3dom scripts
                          in general using the pattern<br>
                          in the ported example.<br>
                          <br>
                          The 'from' portion of Routes into the script
                          would become 'outputchange'<br>
                          listeners attached to the fromNodes with event
                          handlers. The 'to' portion<br>
                          of Routes into the script is used inside the
                          event handler which then calls<br>
                          the appropriate set script function.<br>
                          <br>
                          The directOutput nodes can be retrieved by
                          scene.querySelector(). The SAI<br>
                          node.field syntax can be translated to
                          node.get/setFieldValue or perhaps to<br>
                          node._x3dom.field (or similar).<br>
                          <br>
                          intialize() script functions can be run at
                          document.onload time or probably<br>
                          better using x3dom.runtime.ready<br>
                          <a href="https://doc.x3dom.org/author/runtime.html#ready" rel="noreferrer" target="_blank">https://doc.x3dom.org/author/r<wbr>untime.html#ready</a><br>
                          <br>
                          There are probably lots of pitfalls, and does
                          not address regular (non<br>
                          directOutput) script nodes. -Andreas<br>
                          <br>
                          <br>
                          <br>
                          <br>
                          <br>
                          <br>
                          <br>
                          On Wed, May 31, 2017 at 10:22 PM, Andreas
                          Plesch <<a href="mailto:andreasplesch@gmail.com" target="_blank">andreasplesch@gmail.com</a>><br>
                          wrote:<br>
                          <br>
                          <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
                            John,<br>
                            <br>
                            I could make pretty quick progress to port
                            this to x3d script over to dom<br>
                            scripting style:<br>
                            <br>
                            <a href="https://warm-nape.glitch.me/" rel="noreferrer" target="_blank">https://warm-nape.glitch.me/</a><br>
                            <br>
                            You can 'remix' the code here:<br>
                            <br>
                            <a href="https://glitch.com/edit/#%21/warm-nape" rel="noreferrer" target="_blank">https://glitch.com/edit/#!/war<wbr>m-nape</a><br>
                            <br>
                            [I like <a href="http://glitch.com" rel="noreferrer" target="_blank">glitch.com</a>, and
                            it has a built in server side]<br>
                            <br>
                            The structure is pretty close to the
                            original but probably will need to be<br>
                            more generalized for easy reuse. It is a
                            starting point anyways.<br>
                            <br>
                            There is an initial reset of the green ball
                            translation when it is dragged<br>
                            first. Not sure where this is coming from
                            but may only need minor fixing.<br>
                            <br>
                            For routing, the main idea here is to use
                            the x3dom onoutputchange event<br>
                            as trigger. Other ideas are certainly
                            possible or perhaps necessary for<br>
                            generalization.<br>
                            <br>
                            This uses get/setFieldValue rather than
                            getAttribute because it is more<br>
                            convenient and closer to SAI as it deals
                            with field objects rather than<br>
                            strings.<br>
                            <br>
                            x3dom does not have methods for SFRotations
                            since all rotations get<br>
                            immediately translated to quaternions. But
                            this is a detail at this point.<br>
                            <br>
                            I think I like the idea of returning an
                            object populated by output fields<br>
                            from a main script function.<br>
                            <br>
                            Take a look and feel free to mangle and
                            reorganize,<br>
                            <br>
                            Andreas<br>
                            <br>
                            <br>
                            On Wed, May 31, 2017 at 4:26 PM, Andreas
                            Plesch <<a href="mailto:andreasplesch@gmail.com" target="_blank">andreasplesch@gmail.com</a>><br>
                            wrote:<br>
                            <br>
                            <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
                              Hi John,<br>
                              <br>
                              I am going to take a look but do not wait
                              for anything. I believe x3dom<br>
                              has PlaneSensor.<br>
                              <br>
                              <a href="https://gist.github.com/andreasplesch/83771ec5959935d309db417387397952" rel="noreferrer" target="_blank">https://gist.github.com/andrea<wbr>splesch/83771ec5959935d309db41<wbr>7387397952</a><br>
                              for easy access.<br>
                              <br>
                              -Andreas<br>
                              <br>
                              On Wed, May 31, 2017 at 3:44 PM, John
                              Carlson <<a href="mailto:yottzumm@gmail.com" target="_blank">yottzumm@gmail.com</a>>
                              wrote:<br>
                              <br>
                              <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
                                Can someone port the attached example to
                                X3DOM?  It would help with the<br>
                                X3DOM upgrade effort.<br>
                                <br>
                                <br>
                                <br>
                                Thanks!<br>
                                <br>
                                <br>
                                <br>
                                John<br>
                                <br>
                                <br>
                                <br>
                                ------------------------------<wbr>------------------------------<br>
                                ------------------<br>
                                Check out the vibrant tech community on
                                one of the world's most<br>
                                engaging tech sites, Slashdot.org! <a href="http://sdm.link/slashdot" rel="noreferrer" target="_blank">http://sdm.link/slashdot</a><br>
                                ______________________________<wbr>_________________<br>
                                X3dom-users mailing list<br>
                                <a href="mailto:X3dom-users@lists.sourceforge.net" target="_blank">X3dom-users@lists.sourceforge.<wbr>net</a><br>
                                <a href="https://lists.sourceforge.net/lists/listinfo/x3dom-users" rel="noreferrer" target="_blank">https://lists.sourceforge.net/<wbr>lists/listinfo/x3dom-users</a><br>
                                <br>
                                <br>
                              </blockquote>
                              <br>
                              <br>
                              --<br>
                              Andreas Plesch<br>
                              39 Barbara Rd.<br>
                              Waltham, MA 02453<br>
                              <br>
                            </blockquote>
                            <br>
                            <br>
                            <br>
                            --<br>
                            Andreas Plesch<br>
                            39 Barbara Rd.<br>
                            Waltham, MA 02453<br>
                            <br>
                          </blockquote>
                          <br>
                          <br>
                          <br>
                          -- <br>
                          Andreas Plesch<br>
                          39 Barbara Rd.<br>
                          Waltham, MA 02453<br>
                          <br>
                        </blockquote>
                        <br>
                        <br>
                        ------------------------------<wbr>------------------------------<wbr>--------------------<br>
                        <br>
                        <br>
                        <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
                          ______________________________<wbr>_________________<br>
                          x3d-public mailing list<br>
                          <a href="mailto:x3d-public@web3d.org" target="_blank">x3d-public@web3d.org</a><br>
                          <a href="http://web3d.org/mailman/listinfo/x3d-public_web3d.org" rel="noreferrer" target="_blank">http://web3d.org/mailman/listi<wbr>nfo/x3d-public_web3d.org</a><br>
                          <br>
                        </blockquote>
                        <br>
                        <span class="m_-2326937162992248327gmail-HOEnZb"><font color="#888888">
                          </font></span></blockquote>
                    </div>
                    <span class="m_-2326937162992248327gmail-HOEnZb"><font color="#888888"><br>
                        <br clear="all">
                        <div><br>
                        </div>
                        -- <br>
                        <div class="m_-2326937162992248327gmail-m_6387495155989509503gmail_signature">Andreas
                          Plesch<br>
                          39 Barbara Rd.<br>
                          Waltham, MA 02453</div>
                      </font></span></div>
                </div>
              </div>
            </blockquote>
          </div>
          <br>
          <br clear="all">
          <div><br>
          </div>
          -- <br>
          <div class="m_-2326937162992248327gmail_signature">Andreas Plesch<br>
            39 Barbara Rd.<br>
            Waltham, MA 02453</div>
        </div>
      </div>
      <br>
      <fieldset class="m_-2326937162992248327mimeAttachmentHeader"></fieldset>
      <br>
      </div><pre>------------------------------<wbr>------------------------------<wbr>------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! <a class="m_-2326937162992248327moz-txt-link-freetext" href="http://sdm.link/slashdot" target="_blank">http://sdm.link/slashdot</a></pre><div class="quoted-text">
      <br>
      <fieldset class="m_-2326937162992248327mimeAttachmentHeader"></fieldset>
      <br>
      <pre>______________________________<wbr>_________________
X3dom-users mailing list
<a class="m_-2326937162992248327moz-txt-link-abbreviated" href="mailto:X3dom-users@lists.sourceforge.net" target="_blank">X3dom-users@lists.sourceforge.<wbr>net</a>
<a class="m_-2326937162992248327moz-txt-link-freetext" href="https://lists.sourceforge.net/lists/listinfo/x3dom-users" target="_blank">https://lists.sourceforge.net/<wbr>lists/listinfo/x3dom-users</a>
</pre>
    </div></blockquote>
    <p><br>
    </p>
    <div class="m_-2326937162992248327moz-signature">-- <br><div class="quoted-text">
      <font class="m_-2326937162992248327tahoma,arial,helvetica m_-2326937162992248327san m_-2326937162992248327serif" color="#333366">
        <font size="+1"><b>Leonard Daly</b></font><br>
        3D Systems & Cloud Consultant<br>
        LA ACM SIGGRAPH Chair<br>
        President, Daly Realism - <i>Creating the Future</i>
      </font></div></div>
  </div>

</blockquote></div><br></div></div></div>