[x3d-public] node-java X3DJSAIL and 1 example that works, and one that doesn't

John Carlson yottzumm at gmail.com
Sat Apr 11 20:05:36 PDT 2020


I tried pasting my SAI code into developer tools as you suggest:

var browser = X3D.getBrowser();
var scene = browser.currentScene;
X3D0 = document.querySelector("X3D");
X3D0.profile = "Immersive";

And got:



VM55:4 Uncaught TypeError: Cannot set property 'profile' of null
    at <anonymous>:4:14

Suggestions?  I must be missing something in X_ITE?

John

On Sat, Apr 11, 2020 at 8:40 AM Andreas Plesch <andreasplesch at gmail.com>
wrote:

> Hi John,
>
> x_ite just follows standard SAI, internal or external:
>
> //get Browser
> browser=X3D.getBrowser(); //X3D is global defined by x_ite.js
> //get current scene
> scene=browser.currentScene;
> //make shape node
> shape=scene.createNode('Shape');
> //make box node
> box=scene.createNode('Box');
> //set geometry field
> shape.geometry=box;
> //add as root node (for example)
> scene.addRootNode(shape);
>
> For me the easiest way to experiment with scripting like this, is to
> use the Chrome dev tools console with a simple scene like:
>
> https://www.web3d.org/x3d/content/examples/Basic/UniversalMediaPanoramas/desert3X_ITE.html
> Following the steps will give you a white box visible in the active scene.
>
> x3dom uses the DOM as an interface to the scene. So you create DOM
> elements using HTML5 methods and add those to the Scene DOM element.
> There may be a way to avoid using the DOM and use internal, SAI like
> functions. For example, the javascript domNode._x3dom property gives
> you access to fields and methods for a node. But usually it is easiest
> and most interoperable on a HTML5 page to use the DOM.
>
> The field names are the same across browser but the internal
> representation of field values (as a javascript object) is very
> different. So one cannot use the results of SAI x_ite calls directly
> with x3dom, or vice versa. It is necesssary to go through encodings.
>
> I do not think X3DJSAIL deals a lot with Browser or ExecutionContext
> SAI functions since they are tied to the specific browser but I may be
> wrong.
>
> Andreas
>
> On Sat, Apr 11, 2020 at 2:58 AM John Carlson <yottzumm at gmail.com> wrote:
> >
> > Could Andreas explain how to use createNode in the context of X_ITE SAI?
> > I think that createNode may be the one significant thing missing from
> X3DOM SAI.
> > There's an unrelated one in the physics code.
> >
> > That is, you use createNode to createNodes in SAI, then you use the
> fields of the returned object.  Are these the same across browsers?
> >
> > Here's how to get a node from the standard:
> >
> > Browser.currentScene.createNode('Shape');
> >
> > Again, there is no createNode in X3DJSAIL to speak of.
> >
> > Thanks,
> >
> > John
> >
> > On Sat, Apr 11, 2020 at 1:24 AM John Carlson <yottzumm at gmail.com> wrote:
> >>
> >> We have 2 versions of  JavaScript server side API, Nashorn and Node,
> both dependent on X3DJSAIL, and the code looks similar.  However, we do not
> have a JavaScript native version yet, even with JSweet (it's incomplete).
> >>
> >> I believe that we should pursue an external SAI compatible with X_ITE,
> since X3DOM already has an external SAI.
> >>
> >> Below is an example of "External" with X_ITE. Note that X3D is required
> to be defined, and x_ite.js should be loaded before X3D is called.  So how
> do we do that in node?  This is why I've been suggesting headless browsers!
> >>
> >> ...so...I need to figure out an example of Transform in the standard.
> It would seem like the thing to do would be to implement createNode?  Are
> there any examples of createNode?  Yes, in X_ITE at least.  Do we need to
> create an execution context to use it?  Yes!
> >>
> >> Is there an X_ITE example of external createNode?
> >>
> >> Yes!
> >>
> >> As far as I can tell there is not a X3DOM version of ECMAScript SAI's
> createNode.
> >>
> >> So I think we should start with X_ITE as I said before, and try to
> create an External ECMAScript SAI script (not DOM).
> >>
> >> Do people agree that we should try to create an ECMAScript SAI example
> from outside X_ITE?
> >>
> >> It appears that we either have to start from X3D(), below.   Can we
> make X3D() into an external SAI?
> >>
> >> Do we need a browser in nodejs?
> >>
> >> has anyone looked into chrome embedded framework?
> >>
> >> John
> >>
> >>
> >>
> >>
> -----------------------------------------------------------------------------
> >> function load_X_ITE_XML(content, selector) {
> >>         X3D(function() {
> >>                 var browser = X3D.getBrowser(selector);
> >>
>  browser.replaceWorld(browser.createX3DFromString(content));
> >>         }, function() {
> >>                 alert("Failed to render XML to X_ITE");
> >>         });
> >> }
> >>
> >> function load_X_ITE_DOM(element, selector) {
> >>         X3D(function() {
> >>                 if (typeof X3D.getBrowser !== 'undefined') {
> >>                         var browser = X3D.getBrowser(selector);
> >>                         if (typeof browser !== 'undefined' && typeof
> browser.importDocument !== 'undefined') {
> >>                                 var importedScene =
> browser.importDocument(element);
> >>                                 browser.replaceWorld(importedScene);
> >>                         }
> >>                 }
> >>         }, function() {
> >>                 alert("Failed to render DOM to X_ITE");
> >>         });
> >> }
> >>
> >> function load_X_ITE_JS(jsobj, selector) {
> >>         X3D(function() {
> >>                 if (typeof X3D.getBrowser !== 'undefined') {
> >>                         var browser = X3D.getBrowser(selector);
> >>                         if (typeof browser !== 'undefined' && typeof
> browser.importJS !== 'undefined') {
> >>                                 var importedScene =
> browser.importJS(jsobj);
> >>                                 browser.replaceWorld(importedScene);
> >>                         }
> >>                 }
> >>         }, function() {
> >>                 alert("Failed to render JSON to X_ITE");
> >>         });
> >> }
> >>
> -------------------------------------------------------------------------------------------------------------
> >> John
>
>
>
> --
> Andreas Plesch
> Waltham, MA 02453
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20200411/ff79715c/attachment.html>


More information about the x3d-public mailing list