[x3d-public] [x3dom-users] Cobweb_dom...Script Magic? LoadingDOMsubscenesafterparent in X3DOM and Cobweb. ALMOST complete, requiressequencing ofouterfunctions.

Sven-Erik Tiberg Sven-Erik.Tiberg at ltu.se
Tue Jul 18 04:28:04 PDT 2017


Im on using strope.js ( JScript ) and openfire servers to transfere states between spaces in interupt mode i.e. pushing states in xml format trough secure html using push technique instead of the normal pull technic.

Current state set up a net of openfire servers and testing strope examples.
PS been on this for years and put it on hold due to other tasks, but opened up the project resentley.

Sounds interesting ?
Presently on vacation in Belgium

Sven-Erik Tiberg / sweden.

________________________________
From: x3d-public <x3d-public-bounces at web3d.org> on behalf of John Carlson <yottzumm at gmail.com>
Sent: Tuesday, May 23, 2017 12:34:10 AM
To: Joe D Williams; "John Carlson"
Cc: Leonard Daly; educators at x3dbook.com; list; x3dom mlist
Subject: Re: [x3d-public] [x3dom-users] Cobweb_dom...Script Magic? LoadingDOMsubscenesafterparent in X3DOM and Cobweb. ALMOST complete, requiressequencing ofouterfunctions.

  I don’t use event listeners, I use a setInterval function and JQuery.  How would you suggest modifying this code (the body of the  setInterval function minus the __eventTime incrementer)  to implement the ROUTEs and the X3D Event Model?  Should I do a document.querySelector to get the element, then add a listener?  Then when the listener gets called, call the set function or attr?  What event do I listen for, especially when a script field changes (there are no fields in HTML scripts).  Should I add a proxy to the my script INSTANCE below?  I think I do need a setInterval for the _eventTime.  It can get very complex, but if someone gives me a template, I can start duplicating it.  How do I get existing events from X3DOM sensors and incorporate them into this model?

X3DJSON is my “package”  I probably don’t need the USE attribute.

if (!$("[DEF=DECLBubble_INSTANCE19000_TourTime], [USE=DECLBubble_INSTANCE19000_TourTime]")) console.error("undefined DECLBubble_INSTANCE19000_TourTime");
        X3DJSON.Object_DECLBubble_INSTANCE19000_Bounce.set_fraction($("[DEF=DECLBubble_INSTANCE19000_TourTime], [USE=DECLBubble_INSTANCE19000_TourTime]").attr("cycleTime"), __eventTime);

        if (!$("[DEF=DECLBubble_INSTANCE19000_transform], [USE=DECLBubble_INSTANCE19000_transform]")) console.error("undefined DECLBubble_INSTANCE19000_transform");

        $("[DEF=DECLBubble_INSTANCE19000_transform], [USE=DECLBubble_INSTANCE19000_transform]").attr("translation",typeof X3DJSON.Object_DECLBubble_INSTANCE19000_Bounce.translation_changed === "function" ? X3DJSON.Object_DECLBubble_INSTANCE19000_Bounce.translation_changed() : X3DJSON.Object_DECLBubble_INSTANCE19000_Bounce.translation_changed, __eventTime);

I do this for each prototype instance.  All this code is generated, so you don’t need worry about me writing it more than once.

CAVEAT:  I wrote this code before I knew about JavaScript proxies.
Thanks bunches.

John
Sent from Mail<https://go.microsoft.com/fwlink/?LinkId=550986> for Windows 10

From: John Carlson<mailto:yottzumm at gmail.com>
Sent: Monday, May 22, 2017 5:59 PM
To: Joe D Williams<mailto:joedwil at earthlink.net>; "John Carlson"<mailto:john.carlson3 at sbcglobal.net>
Cc: Leonard Daly<mailto:Leonard.Daly at realism.com>; list<mailto:x3d-public at web3d.org>; x3dom mlist<mailto:x3dom-users at lists.sourceforge.net>; educators at x3dbook.com<mailto:educators at x3dbook.com>
Subject: RE: [x3dom-users] Cobweb_dom...Script Magic? LoadingDOMsubscenesafterparent in X3DOM and Cobweb. ALMOST complete,requiressequencing ofouterfunctions.

Let me send you my example code and we’ll see how it might be modified.

John

Sent from Mail<https://go.microsoft.com/fwlink/?LinkId=550986> for Windows 10

From: Joe D Williams<mailto:joedwil at earthlink.net>
Sent: Monday, May 22, 2017 5:51 PM
To: "John Carlson"<mailto:yottzumm at gmail.com>; "John Carlson"<mailto:john.carlson3 at sbcglobal.net>
Cc: Leonard Daly<mailto:Leonard.Daly at realism.com>; list<mailto:x3d-public at web3d.org>; x3dom mlist<mailto:x3dom-users at lists.sourceforge.net>; educators at x3dbook.com<mailto:educators at x3dbook.com>
Subject: Re: [x3dom-users] Cobweb_dom...Script Magic? LoadingDOMsubscenesafter parent in X3DOM and Cobweb. ALMOST complete,requiressequencing ofouter functions.

John, isn't the real contribution of the X3d event system is simply
the easy way to attach listeners to a node? Also that it is easy to
document the listener and the path or route the event to the nexxt
step in processing. Well, I guess also the built-in abilities to group
events streams in cascade, evaluate the cascade, then apply them to
the scenegraph as if 'instantatneously' for time and event based
simulation. Finally, just the way that an X3D scene can be treated as
an entity which an be controlled by a outside entity in the same way
as an internal entity.

Maybe there are other important details,

All Best Wishes,
Joe

----- Original Message -----
From: "John Carlson" <john.carlson3 at sbcglobal.net>
To: "John Carlson" <yottzumm at gmail.com>
Cc: "Leonard Daly" <Leonard.Daly at realism.com>; "list"
<x3d-public at web3d.org>; <X3D>; <x3dom-users at lists.sourceforge.net>
Sent: Monday, May 22, 2017 10:38 AM
Subject: Re: [x3dom-users] Cobweb_dom...Script Magic? Loading
DOMsubscenesafter parent in X3DOM and Cobweb. ALMOST complete,
requiressequencing ofouter functions.


> If someone could provide sample JavaScript code which even gets
> close to implementing the X3D event model (in HTML if you like) for
> a couple of sample ROUTEs, I could probably take it from there.   Or
> a potential event model replacement.  A simple loop apparently
> doesn't cut it?
>
>
> Thanks!
>
>
> John
>
>
> On May 22, 2017 11:58 AM, John Carlson <yottzumm at gmail.com> wrote:
>
>  In summary, X3D ecmascript and HTML ecmascript are mostly
> compatible, except for DOM and SAI. Â  I believe Cobweb supports
> both DOM and SAI, but I could  be corrected.  What is different
> with X3D are 1) fields and 2) ROUTEs. Â  I think we can share the
> same script tag if fields are added to HTML scripts, possibly
> through some kind of extension or conversion.  Fields are currently
> required for ROUTEs. Â  If there was a conversion mechanism for
> ROUTEs, that would be helpful, and would avoid having to have fields
> on scripts.
>
>
>  John
>
>
>  On May 22, 2017 11:20 AM, "John Carlson" <yottzumm at gmail.com>
> wrote:
>
>      1.. You don’t have to have HTML script in <script></script>Â
> you can eval them.  You do need X3D Script fields for ROUTES. I am
> asking for script fields, not script tags.  I am fine with the HTML
> script node, except I just want fields that I can route to.  If you
> provide ROUTEs to non-X3D things that would be an OK alternate by
> me, too, or a just way to convert X3D Script-based ROUTEs to
> JavaScript.
>      2.. Self-modifying scripts are a bad idea. LOL.
>    Â
>
>    Again, I am not asking for strict X3D Scripts.  I can build an
> SAI library or get one if I want to.  I am asking for a way to
> ROUTE between X3D and JavaScript (and by happy circumstance,
> JavaScript to JavaScript).  That is how you need to keep X3D
> relevant, if you want to maintain a standard, and that’s how you
> make everyone happy.  If there’s a conversion tool, that’s OK
> by me.  Are you going to write it?
>
>    Â
>
>    John
>
>    Â
>
>    Sent from Mail for Windows 10
>
>    Â
>
>    From: Leonard Daly
>    Sent: Monday, May 22, 2017 11:01 AM
>    To: John Carlson
>    Subject: Re: [x3dom-users] Cobweb_dom...Script Magic? Loading
> DOMsubscenesafter parent in X3DOM and Cobweb. ALMOST complete,
> requiressequencing ofouter functions.
>
>    Â
>
>    On 5/22/2017 7:12 AM, John Carlson wrote:
>
>      The Script AND the Proto problem have ben solved in the HTML
> environment, I believe, with Cobweb + Cobweb DOM, or close to it.Â
> See Cobweb 3.2.
>
>
>    John,
>
>    Script is very far from being solved, and (I believe) unsolvable
> with the constraints of X3D and DOM. These are my reasons.
>    1) There is a name conflict so X3D Script cannot be in the same
> namespace as HTML's Script. HTML only has one namespace
>    2) DOM allows scripts to modify themselves or be modified by
> other scripts. This is not possible in Cobweb or Cobweb_DOM.
>
>    3) If you create a new node called (for example) X3dScript
> replacing the current X3D's Script node you solve (1) and because
> it's not JavaScript in the DOM, (2) is irrelevant. Now a scene has
> two different scripting environments. Even though the code looks to
> be the same (written in the same language), one cannot access
> fields, methods, properties, etc. of the other. They have different
> calling mechanisms. The X3dScript node code cannot respond to HTML
> events (mouseover, click, typing, etc in HTML elements). The
> HTML/DOM Script code can only interact with X3D elements through
> X3D's SAI. This design would produce an environment that has minimal
> (even less than current X3D) adoption. It would be confusing to
> developers with no obvious reason to the separate design.
>
>
>    Leonard Daly
>
>      John
>
>      Â
>
>      Sent from Mail for Windows 10
>
>      Â
>
>      From: Leonard Daly
>      Sent: Monday, May 22, 2017 10:06 AM
>      To: John Carlson
>      Cc: X3D Graphics public mailing list;
> x3dom-users at lists.sourceforge.net; Andreas Plesch;
> holger.seelig at yahoo.de
>      Subject: Re: [x3dom-users] Cobweb_dom...Script Magic? Loading
> DOM subscenesafter parent in X3DOM and Cobweb. ALMOST complete,
> requires sequencing ofouter functions.
>
>      Â
>
>      John,
>
>      I have not been convinced that Protos need to exist in an HTML
> environment. Scripts are an integral piece of the Proto architecture
> so if you path is to implement Protos on the way to implementing
> Scripts, you need to solve the entire Script problem first. If
> Scripts are optional, then why have Proto? I think something like a
> macro expansion can solve all of the use cases where Proto would be
> used while being lighter weight and easier to implement and possibly
> use.
>
>      Leonard Daly
>
>
>
>
>        Leonard, I believe Scripts should be implemented AFTER
> Protos.   Just my opinion.  Once the Protos and the ROUTEs and the
> Scripts are expanded with the new DEFs, then you apply the event
> model. Â  This makes things easier, but takes more memory. Â  Then
> you optimize. Â  Beware premature optimization.
>
>        Â
>
>        John
>
>        Â
>
>        On May 21, 2017 12:16 AM, "Leonard Daly"
> <Leonard.Daly at realism.com> wrote:
>
>          John,
>
>          I don't really like to answer this way, but why?
>
>          X3DOM does not have Proto/ExternProto feature. It does not
> have X3D Script node. The integration with HTML is too close to
> allow an X3D Script node. HTML JavaScript (via DOM and X3D node
> manipulation) is available and used extensively. X3DOM does not
> handle VRML (meaning a text file with {} syntax). There is an
> unofficial JSON loader. Perhaps you have one too. How does it get
> the scene graph into DOM? Does it create DOM elements (or perhaps an
> HTML text string which is then parsed)? Something else?
>
>          To the extent I understand your question, you are asking
> for help in constructing a means of handling X3D Script node in
> X3DOM. Once that is done, Proto/ExternProto would be next. This
> would all come into the browser through an JSON encoded file. It
> seems to me that trying to handle X3D Script code requires an entire
> infrastructure supporting the X3D event mode and calling script code
> with X3D arguments. It also requires building full support for SAI
> and supporting the 'directOutput' field. That is a major effort with
> no obvious purpose that I see in V4.
>
>          You are asking for some serious time support (I think) into
> an application that is neither fully X3D-compliant, nor
> DOM-compliant (but the closest to both that is available). At least
> for me, I do not understand how this effort would further an X3D
> integrated DOM system. I am quite willing to listen to your reasons
> and help where I can, but I would like to see where this is going
> first.
>
>          Leonard Daly
>
>          P.S.  Everything above is for client-side code. Server
> side code can manipulate things as much as it wants to create
> something that runs in a client-side browser.
>
>          P.P.S. I do think there is a need to JSON encoding in V4
> subject to the node definition for V4.
>
>
>
>
>
>            Yes, Leonard, for quite some time I have an X3D JSON
> PROTOtypeExpander.js that works with X3D PROTOs and EXTERNPROTOs and
> displays in X3DOM.  I don’t know how complete it is, and testers
> are welcome. My EXTERNPROTO expander runs on the server, so is not
> included in the message, but it is included in the link in the
> original message.  If someone can make the EXTERNPROTO expander
> work client side that would be great.
>
>            Â
>
>            The EXTERNPROTO expander is generally called like:
>
>            Â
>
>            Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â  json =
> externPrototypeExpander(outfile, json);
>
>            Â
>
>            Where json is the parent json of the extern, and outfile
> is the parent X3D file being loaded (I think “” will probably do
> in a pinch.  I am not sure.).  The extern PROTOs will be included
> in the original JSON as a ProtoDeclare object.  You may have to run
> the flattener afterwards, and it is run as:
>
>            Â
>
>            Â Â Â Â Â Â Â Â Â Â Â  json = flattener(json);
>
>            Â
>
>            It removes empty objects from the JSON.
>
>            Â
>
>            Yes, I would like someone to help me with VRMLScript for
> X3DOM, if someone is available.  I have a very barebones and
> incorrect implementation here:
>
>            Â
>
>
> https://github.com/coderextreme/X3DJSONLD/blob/master/src/main/node/Script.js
>
>            Â
>
>            Please help.  I don’t know the X3D event model, and
> I’m not likely to learn soon.  The X3D event model can be
> emulated in Browser-side JavaScript, but there’s only Cobweb for
> proof.
>
>
>            I have another version of flipper.html here that works
> with X3DOM and Cobweb adding the subscene later.  It works with
> Promises, but the functions still aren’t separated…close, but no
> cigar.  Take a look:
>
>            Â
>
>
> https://github.com/coderextreme/X3DJSONLD/blob/master/src/main/html/flipper.html
>
>            Â
>
>            Sorry, I tend to use the XML version of “Proto”, and
> not the VRML “PROTO”.
>
>            Â
>
>            X3DJSONLD provides an infrastructure for X3D JSON Browser
> development, including X3D XML -> X3D JSON conversion on the server,
> and X3D JSON to X3D XML loading into X3DOM and Cobweb.  It also
> includes conversions from XML DOM to Java and Nashorn JavaScript for
> X3DJSAIL app development.
>
>            Â
>
>            There is definite potential for an XML PROTO expander, as
> I have written this code, but not seriously tested:
>
>            Â
>
>
> https://github.com/coderextreme/X3DJSONLD/blob/master/src/main/node/CompleteXMLPrototypeExpander.js
>
>            Â
>
>            So far, it’s still server-side.  If you’re going to
> modify it, split it into server and client-side pieces, please.Â
> Complete is probably a misnomer…
>
>            Â
>
>            Thanks,
>
>            Â
>
>            John
>
>            Â
>
>            Sent from Mail for Windows 10
>
>            Â
>
>            From: Leonard Daly
>            Sent: Saturday, May 20, 2017 7:17 PM
>            To: John Carlson; Andreas Plesch; holger.seelig at yahoo.de
>            Cc: x3dom-users at lists.sourceforge.net; X3D Graphics
> public mailing list
>            Subject: Re: [x3dom-users] Cobweb_dom...Script Magic?
> Loading DOM subscenesafter parent in X3DOM and Cobweb.
>
>            Â
>
>            John,
>
>              Cobweb_dom, X3DOM experts, I need some help adding a
> child DOM scenegraph with prototypes to a parent DOM scenegraph
> after the
>
>
>            Not sure how any of this applies to X3DOM as it does not
> have PROTOs. Assuming you mean X3D prototypes via PROTO or
> EXTERNPROTO. If you mean something else, please elaborate.
>
>
>            Leonard Daly
>
>
>
>
>              primary scene has been  loaded, and not before. I have
> an example of loading before the scene is loaded, and in a
> callback.  If you have an example with Promises instead of callback
> nesting, that would be more ideal, the second $.getJSON() (child
> scenegraph) might finish before the first $.getJSON() (parent
> scenegraph) if I don’t use promises or callback nesting. Also,
> Promises would allow me to separate the parent loading somewhat from
> the child loading, and create separate functions.  Also, X3DOM
> experts can provide an example with Promises as well.  Meanwhile, I
> will be reading about Promises.
>
>              Â
>
>              Here is my example so far:
>
>
> https://github.com/coderextreme/X3DJSONLD/blob/master/src/main/html/flipper.html
>
>              Viewable here:
>
>
> https://coderextreme.net/X3DJSONLD/src/main/html/flipper.html
>
>              Â
>
>              The white Box is the subscene of the dolphin scene.
>
>              Â
>
>              The following related code is from
> https://github.com/coderextreme/X3DJSONLD/blob/master/src/main/node/loaderJQuery.js
>
>              and references code from:
>
>              Â
>
>
> https://github.com/coderextreme/X3DJSONLD/blob/master/src/main/node/X3DJSONLD.js
>
>              [ actually, I think the last two reference each other
> – naughty ]
>
>              Â
>
>              Data is here:
>
>              [ child scenegraph ]
>
>
> https://github.com/coderextreme/X3DJSONLD/blob/master/src/main/data/abox.json
>
>              Â
>
>              [ parent scenegraph ]
>
>
> https://github.com/coderextreme/X3DJSONLD/blob/master/src/main/data/flipp.json
>
>              Â
>
>              Â
>
>              Cobweb doesn’t need the prototypeExpander or the
> flattener (well, it might have with prototypes in cobweb_dom, but I
> think the last release fixed that…haven’t checked—here is a
> good test for you!).  This is a dual example, and I haven’t
> figured out how to conditionally run the prototypeExpander on only
> X3DOM code.  Please test without the PrototypeExpander.js and
> Flattener.js included, and remove X3DOM, since it won’t work in
> that case.  X3DOM folks can include the two JavaScript files which
> are here:
>
>              Â
>
>
> https://github.com/coderextreme/X3DJSONLD/blob/master/src/main/node/PrototypeExpander.js
>
>
> https://github.com/coderextreme/X3DJSONLD/blob/master/src/main/node/Flattener.js
>
>              Â
>
>              Â
>
>              You may provide your own appendInline (below) which
> doesn’t call loadSchema.  That may be too complex of a download.Â
> That is, you probably don’t want to do all that JSON schema
> validation in your example.  Try to keep my code close to what it
> is otherwise.
>
>              Â
>
>              And if you start supporting X3D JSON in your viewers,
> that would be even better!
>
>              Â
>
>              John
>
>              Â
>
>              /**
>
>              ·         Next is passed the element parameter
>
>              ·         */
>
>              function appendInline(element, url, next) {
>
>              Â Â Â Â Â Â Â  $.getJSON(url, function(json) {
>
>              Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â  if (typeof
> prototypeExpander === 'function') {
>
>              Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â  json =
> prototypeExpander(url, json, "");
>
>              Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â  } else {
>
>              Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â
> console.error("Perhaps you need to include the
> PrototypeExpander.js?");
>
>              Â Â Â Â Â Â  Â Â Â Â Â Â Â Â Â }
>
>              Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â  if (typeof flattener ===
> 'function') {
>
>              Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â  json =
> flattener(json);
>
>              Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â  } else {
>
>              Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â
> console.error("Perhaps you need to include the Flattener.js?");
>
>              Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â  }
>
>              Â Â Â Â Â Â Â Â Â Â  Â Â Â Â Â // must validate here
> because we call an inner method.
>
>              Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â  loadSchema(json, url,
> doValidate, function() {
>
>              Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â
> ConvertToX3DOM(json["X3D"]["Scene"], "Scene", element, url);
>
>              Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â
> next(element);
>
>              Â Â Â Â Â Â Â Â  Â Â Â Â Â Â Â }, function(e) {
>
>              Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â
> console.error(e);
>
>              Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â  });
>
>              Â Â Â Â Â Â Â  }).fail(function(jqXHR, textStatus,
> errorThrown) { alert('getJSON request failed! ' + textStatus + ' ' +
> errorThrown); });
>
>              }
>
>              Â
>
>              /**
>
>              ·         Next is passed the selected element
> from selector
>
>              ·         Selector is the CSS selector to
> append inline to.
>
>              ·         */
>
>              function loadSubscene(selector, url, next) {
>
>              Â Â Â Â Â Â Â
> appendInline(document.querySelector(selector), url, next);
>
>              }
>
>              Â
>
> ------------------------------------------------------------------------------Check
> out the vibrant tech community on one of the world's mostengaging
> tech sites, Slashdot.org! http://sdm.link/slashdotÂ
>
> _______________________________________________X3dom-users mailing
> listX3dom-users at lists.sourceforge.nethttps://lists.sourceforge.net/lists/listinfo/x3dom-usersÂ
>
>            --
>            Leonard Daly
>            3D Systems & Cloud Consultant
>            LA ACM SIGGRAPH Chair
>            President, Daly Realism - Creating the Future
>
>            Â
>
>          Â
>
>          --
>          Leonard Daly
>          3D Systems & Cloud Consultant
>          LA ACM SIGGRAPH Chair
>          President, Daly Realism - Creating the Future
>
>      Â
>
>      --
>      Leonard Daly
>      3D Systems & Cloud Consultant
>      LA ACM SIGGRAPH Chair
>      President, Daly Realism - Creating the Future
>
>      Â
>
>    Â
>
>    --
>    Leonard Daly
>    3D Systems & Cloud Consultant
>    LA ACM SIGGRAPH Chair
>    President, Daly Realism - Creating the Future
>
>    Â
>
>
>


--------------------------------------------------------------------------------


> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot


--------------------------------------------------------------------------------


> _______________________________________________
> X3dom-users mailing list
> X3dom-users at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/x3dom-users
>



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20170718/10f0187d/attachment-0001.html>


More information about the x3d-public mailing list