[x3d-public] Difficult bug in X3DJSONLD, files by Andreas and myself show same problem as index.html, perhaps
John Carlson
yottzumm at gmail.com
Tue Jun 15 07:51:36 PDT 2021
I have also discovered that if I put a breakpoint in the debugger in
JSONParser.java, below, my scene works much better. I will try to get
some examples out soon.
JSONParser .prototype.
parseJavaScript = function(jsobj, success, error) {
var child = this.CreateElement('X3D'); // <<<<< breakpoint
here.
this.ConvertToX3DOM(jsobj, "", child);
// call the DOM parser
this.parseIntoScene(child, success, error);
return child;
};
On 6/15/21 6:40 AM, Holger Seelig wrote:
> Hello John,
>
> There was indeed a bug in X_ITE, in importJS, that the .dom property
> of the resulting scene was not set. This is fixed now. I also updated
> the documentation that there is also an async version of .importJS.
> The async version must be used if you specify profile or components
> that are not in the main packaged of X_ITE, like the Layout component,
> which is loaded later, only if needed. But you can also use the sync
> version if you only need VRML.
>
> See:
> https://github.com/create3000/x_ite/wiki/Browser-Services#x3dscene-importdocument-domobject-dom
> <https://github.com/create3000/x_ite/wiki/Browser-Services#x3dscene-importdocument-domobject-dom>
>
> Here is a full example:
>
> <html>
> <head>
> <meta charset="utf-8"/>
> <link rel="stylesheet" type="text/css"
> href="https://create3000.github.io/code/x_ite/latest/dist/x_ite.css
> <https://create3000.github.io/code/x_ite/latest/dist/x_ite.css>"/>
> <script type="text/javascript"
> src="https://create3000.github.io/code/x_ite/latest/dist/x_ite.min.js
> <https://create3000.github.io/code/x_ite/latest/dist/x_ite.min.js>"></script>
> <style type="text/css">
> X3DCanvas {
> width: 768px;
> height: 432px;
> }
> </style>
> <script
> src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js
> <https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js>"></script>
> <script>
> function load ()
> {
> console .log ("load");
> $.getJSON ("Billboard.x3dj", function (json)
> {
> X3D (function ()
> {
> var Browser = X3D .getBrowser ();
> Browser .importJS (json, function (scene)
> {
> Browser .replaceWorld (scene);
> console .log (scene .dom);
> });
> });
> });
> }
> </script>
> </head>
> <body>
> <X3DCanvas></X3DCanvas>
> <button onclick="load()">Click Me!</button>
> </body>
> </html>
>
>
>> Am 15.06.2021 um 03:19 schrieb John Carlson <yottzumm at gmail.com
>> <mailto:yottzumm at gmail.com>>:
>>
>> Holger,
>>
>>
>> My main code currently looks like the below. I believe I patched the
>> problem with ajv internationalization in loaderJQuery.js
>>
>> Umm, to me, it looks like your shader programs aren't working--the
>> "Program" in the console log, even though they downloaded
>> successfully? I'm not sure if the shaders are related to your
>> initial graphics, or something else. Initial graphics seem to be
>> working. Perhaps there's an issue with the url file/path?
>>
>> <script type="text/javascript">
>>
>> var url = "../data/ArchHalf.json";
>> var selector = "#x_itedom";
>>
>> function importInto_X_ITE(json) {
>> loadX3DJS_X_ITE(selector, document.implementation,
>> json, url, "", loadSchema, doValidate, X3DJSONLD, function(jsDOM) {
>> load_X_ITE_DOM(jsDOM, selector);
>> });
>> }
>> $(document).ready(function() {
>> $.getJSON(url, importInto_X_ITE);
>> });
>>
>> </script>
>>
>> ====================================================================================================
>>
>> The error seems to be in this showing up in this code in X3DJSONLD.
>> It looks like child.dom is undefined on the return from
>> browser.importJS. I'm guessing there was some change to X_ITE or
>> x_ite_dom?
>>
>> I tried including x_ite_dom 1.3. child.dom is still the same. So it
>> looks like I broke encapsulation. Hmm. This will take some
>> investigation. It may be that the return value from
>> JSONParser.parseJavaScript() is undefined! Hmm. Well, back to debugger.
>>
>> function loadX3DJS_X_ITE(selector, DOMImplementation, jsobj, path,
>> NS, loadSchema, doValidate, X3DJSONLD, callback) {
>> X3DJSONLD.x3djsonNS = NS;
>> loadSchema(jsobj, path, doValidate, X3DJSONLD, function() {
>> X3D(function() {
>> if (typeof X3D.getBrowser !== 'undefined') {
>> var browser = X3D.getBrowser(selector);
>> if (typeof browser !== 'undefined' && typeof
>> browser.importJS !== 'undefined') {
>> var child = browser.importJS(jsobj);
>> var xml = X3DJSONLD.serializeDOM(jsobj,
>> child.dom, true);
>> callback(child.dom, xml);
>> }
>> }
>> }, function() {
>> alert("Failed to render JSON to X_ITE");
>> });
>> }, function(e) {
>> console.error(e);
>> callback(null, null);
>> });
>> }
>>
>> On 6/4/21 7:34 AM, John Carlson wrote:
>>> My load functions, particularly load_X_ITE_DOM should call the X3D
>>> function.
>>>
>>> The error in index.js is in the JSON validation suite, and hopefully
>>> not escaping the try/catch. I was noticing that the element was
>>> undefined, and that may be the result of something not valid.
>>> Clicking ok on the validation error pop up should take one past
>>> validation. One should try to find a valid JSON file to load with
>>> APjsonImport.xhtml . I am going to sleep now and will try to
>>> pursue this tonight.
>>>
>>> On Fri, Jun 4, 2021 at 6:26 AM Holger Seelig <holger.seelig at yahoo.de
>>> <mailto:holger.seelig at yahoo.de>> wrote:
>>>
>>> The most common mistake is that the X3D Browser is not available
>>> from the beginning of the HTML page. Thus a call to the X3D
>>> function to access the Browser must be wrapped, see:
>>>
>>> https://github.com/create3000/x_ite/wiki/Accessing-the-External-Browser
>>> <https://github.com/create3000/x_ite/wiki/Accessing-the-External-Browser>
>>>
>>>
>>> But there are is also this error in the console
>>>
>>> [Error] Failed to load resource: the server responded with a
>>> status of 404 () (index.js, line 0)
>>> https://coderextreme.net/X3DJSONLD/src/main/node/ajv-i18n/localize/de-de/index.js
>>> <https://coderextreme.net/X3DJSONLD/src/main/node/ajv-i18n/localize/de-de/index.js>
>>>
>>> Holger
>>>
>>>
>>>> Am 04.06.2021 um 12:43 schrieb John Carlson <yottzumm at gmail.com
>>>> <mailto:yottzumm at gmail.com>>:
>>>>
>>>> I'm trying to get these working:
>>>>
>>>> https://coderextreme.net/X3DJSONLD/src/main/html/AP_minimal_JSLD.html
>>>> <https://coderextreme.net/X3DJSONLD/src/main/html/AP_minimal_JSLD.html>
>>>>
>>>> https://coderextreme.net/X3DJSONLD/src/main/html/AP_minimal_JSLD.xhtml
>>>> <https://coderextreme.net/X3DJSONLD/src/main/html/AP_minimal_JSLD.xhtml>
>>>>
>>>> This may provide some guidance:
>>>>
>>>> https://coderextreme.net/X3DJSONLD/src/main/html/APjsonImport.xhtml
>>>> <https://coderextreme.net/X3DJSONLD/src/main/html/APjsonImport.xhtml>
>>>> or at least somewhat easy selection of files, and both X3DOM
>>>> (works) and X_ITE (fails). (Feel free to reduce number of files
>>>> in <select>)
>>>>
>>>> I realize I could probably use older versions of X_ITE, but I'm
>>>> more interested in possible current features I'm missing.
>>>>
>>>> I am not having issues with Inline with *.json files, as far as
>>>> I can tell, mostly just index.html
>>>>
>>>> Repository is below, master branch.
>>>>
>>>> https://github.com/coderextreme/X3DJSONLD/
>>>> <https://github.com/coderextreme/X3DJSONLD/>
>>>>
>>>> Thanks for any basic assistance you have.
>>>>
>>>> It's highly likely I may have problems with the JSON schema.
>>>>
>>>> I will now look at X_ITE documentation.
>>>>
>>>> John
>>>>
>>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20210615/6f93e57f/attachment-0001.html>
More information about the x3d-public
mailing list