[x3d-public] [x3dom-users] Bad rendering of JSON SimpleShader in X_ITE
Leonard Daly
Leonard.Daly at realism.com
Thu May 24 06:48:08 PDT 2018
John,
Yvonne created an example with a JSON loader about 4 years ago. I forget
the details. Don may remember more. I think she used the NPS Monterey
Bay Aquarium dolphin.
Leonard Daly
On 5/23/2018 9:10 PM, John Carlson wrote:
> After some consideration, I will move the JSON -> DOM out of X3DJSONLD
> and into X3DOM, since I already have code for it in X3DOM. However, I
> need an X3DOM interface for loading JavaScript objects into X3DOM.
> Suggestions?
>
> On Wed, May 23, 2018, 11:58 PM Leonard Daly <Leonard.Daly at realism.com
> <mailto:Leonard.Daly at realism.com>> wrote:
>
> On 5/23/2018 7:53 PM, John Carlson wrote:
>>
>> Okay, I tested importDocument, and it works, so that points to
>> X_ITE importJS being the problem. If someone can get me a way to
>> build x_ite from scratch, I will start work getting JSONParser
>> and the CDATA stuff up to date in X_ITE. If that doesn’t solve
>> the problem I will have to dig deeper.
>>
>> Does anyone know how to deep clone a DOM? I’d like to render
>> both X_ITE and X3DOM from similar DOM trees without having to
>> retranslate the JSON to DOM (adding another output to X3DJSONLD).
>>
>
> John,
>
> X3DOM puts internal data structures in the DOM (e.g., the runtime
> structure is attached to each X3DOM tag). You will need to deal
> with circular references (legal in DOM, not in JSON) and other
> very squirrelly things. You can do a clone on a DOM node (deep or
> shallow) with <element>.cloneNode(). See
> https://developer.mozilla.org/en-US/docs/Web/API/Node/cloneNode
> for details.
>
>
> Leonard Daly
>
>
>
>
>> Thanks,
>>
>> John
>>
>> Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986>
>> for Windows 10
>>
>> *From: *John Carlson <mailto:yottzumm at gmail.com>
>> *Sent: *Wednesday, May 23, 2018 4:30 AM
>> *To: *Don Brutzman <mailto:brutzman at nps.edu>; Andreas Plesch
>> <mailto:andreasplesch at gmail.com>; holger.seelig at yahoo.de
>> <mailto:holger.seelig at yahoo.de>; X3D Graphics public mailing list
>> <mailto:x3d-public at web3d.org>; x3dom mlist
>> <mailto:x3dom-users at lists.sourceforge.net>
>> *Subject: *RE: Bad rendering of JSON SimpleShader in X_ITE
>>
>> Okay, I’ve narrowed another part of it down to:
>>
>> "#sourceText": [
>>
>> "data:text/plain;charset=utf-8,",
>>
>> Produces correct X_ITE **XML** renderings in X3DJSONLD,
>> translating from JSON to XML.
>>
>> "#sourceText": [
>>
>> "",
>>
>> " data:text/plain;charset=utf-8,",
>>
>> "",
>>
>> Generated by X3dToJson.xslt, does not produce correct XML
>> rendering in X3DJSONLD. And neither does:
>>
>> "#sourceText": [
>>
>> I will trim() strings in X3DJSONLD CDATA sections—I have fixed
>> this in X_ITE as well, but I’ve been unable to build, but may
>> want to rely on X3dToJson.xslt to do the right thing in the future.
>>
>> This does not fix the X_ITE JSON rendering in either X_ITE or
>> X3DJSONLD (X_ITE JSON rendering in X3DJSONLD **is** X_ITE 4.1.5).
>> There *appears* to be the desire to load ShaderPart CDATA
>> sections (if they are in fact CDATA sections…I have not confirmed
>> this) as URLs. Currently, in X_ITE, I convert all #sourceText
>> as a CDATA section using Andreas’ method for creating a CDATA
>> section with DOMParser, which I replaced in X3DJSONLD, due to
>> issues with Edge.
>>
>> So how do we solve the problem of rendering JSON in X_ITE? I am
>> getting the following:
>>
>> Failed to load data:text/plain;charset=utf-8,precision mediump
>> float;uniform mat4 x3d_ProjectionMatrix;uniform mat4
>> x3d_ModelViewMatrix;uniform mat3 x3d_NormalMatrix;attribute vec4
>> x3d_Vertex;attribute vec3 x3d_Normal;varying vec3 normal;void
>> main(){normal = x3d_NormalMatrix * x3d_Normal;gl_Position =
>> x3d_ProjectionMatrix * x3d_ModelViewMatrix * x3d_Vertex;}
>> ?_=1527054157284: Invalid response. Origin
>> 'http://localhost:3000' is therefore not allowed access.
>>
>> There are “network loads” (appear under Network tab in developer
>> tools on Chrome) which don’t appear with the XML version. The
>> above is one of them. Apparently the XML version does something
>> different than the JSON version, even though the JSON is
>> translated to DOM in X_ITE. It is possible that I didn’t
>> actually create a CDATA section with the JSON version, that needs
>> to be checked, if nothing else has been fixed or comes to mind.
>> This has been a problem with serializing DOM to XML with Edge
>> (CDATA tag disappeared), but I haven’t seen it otherwise.
>>
>> Attached are the tested versions of SimpleShader.json and
>> SimpleShader.x3d, minus non-x_ite shaders.
>>
>> I need help building x_ite from scratch (I removed my copy), see
>> issue on GitHub. Make all fails.
>>
>> Note: I have not tested importDocument, just createX3DFromString
>> and importJS and specifying urls on X3DCanvas.
>>
>> Sorry I didn’t get to testing embedded Shaders sooner with X3DOM
>> and X_ITE, it slipped my mind, and I didn’t realize the Examples
>> folder didn’t cover embedded ShaderPart’s. The Shaders tests are
>> under Components…
>>
>> People can comment on my CDATACreateFunction and fixXML sections
>> of JSONParser (X3DJSONLD.js). They likely need work.
>>
>> Patches are welcome too! But please run “sh local.sh” in
>> src/main/shell and peruse the diffs (yes, I know they are
>> horrible). At a minimum, run “sh quotetest.sh” (I just checked,
>> those diffs are horrible too!). Sigh! I’m not sure what’s
>> holding this ball of wax together.
>>
>> Does anyone want to do a massive conversion of x_ite’s test
>> Library to X3D JSON?
>>
>> Also help with ProtoExpander on below would be welcome.
>>
>> I think I can finally send this email.
>>
>> John
>>
>> Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986>
>> for Windows 10
>>
>> *From: *John Carlson <mailto:yottzumm at gmail.com>
>> *Sent: *Tuesday, May 22, 2018 5:57 PM
>> *To: *Don Brutzman <mailto:brutzman at nps.edu>; Andreas Plesch
>> <mailto:andreasplesch at gmail.com>; holger.seelig at yahoo.de
>> <mailto:holger.seelig at yahoo.de>; X3D Graphics public mailing list
>> <mailto:x3d-public at web3d.org>; x3dom mlist
>> <mailto:x3dom-users at lists.sourceforge.net>
>> *Subject: *RE: Bad rendering of JSON SimpleShader in X_ITE --
>> Also Bug inX3DOMProtoExpander.
>>
>> When I got rid of the space leading into data:text/string in the
>> Cobweb shaders, the XML rendered properly. So it’s the leading
>> space generate either by the XML -> JSON translation
>> (DOM2JSONSerializer.js) or the JSON -> DOM -> XML which is
>> preventing the XML from rendering. I will switch to
>> X3dToJson.xslt and see if that fixes it.
>>
>> John
>>
>> Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986>
>> for Windows 10
>>
>> *From: *John Carlson <mailto:yottzumm at gmail.com>
>> *Sent: *Tuesday, May 22, 2018 5:30 PM
>> *To: *Don Brutzman <mailto:brutzman at nps.edu>; Andreas Plesch
>> <mailto:andreasplesch at gmail.com>; holger.seelig at yahoo.de
>> <mailto:holger.seelig at yahoo.de>; X3D Graphics public mailing list
>> <mailto:x3d-public at web3d.org>; x3dom mlist
>> <mailto:x3dom-users at lists.sourceforge.net>
>> *Subject: *RE: Bad rendering of JSON SimpleShader in X_ITE --
>> Also Bug in X3DOMProtoExpander.
>>
>> Probably it’s not passing schema in X3DJSONLD because of the
>> ProtoExpander. The ProtoExpander does not exist in X_ITE to my
>> knowledge (but it may have it’s own version).
>>
>>
>> When I turn off the proto expander in X3DJSONLD, and the schema
>> does not report an error. The shader only takes affect in XML
>> when I load XML. When I turn off the proto expander in
>> X3DJSONLD, the JSON still does not render properly in X_ITE (as
>> evidenced by the previous collection of files I submitted).
>>
>> The online validator reports no error with the non-proto expanded
>> JSON.
>>
>> Attached is the expanded JSON and schema errors.
>>
>> The schema error seems to surround:
>>
>> "@decis": [
>>
>> 0.95,
>>
>> 0.44,
>>
>> 0.22
>>
>> ],
>>
>> Which should be an @value on the field, so the schema error is
>> definitely an issue with the ProtoExpander. This may affect and
>> likely does affect X3DOM.
>>
>>
>> I doubt if this will shed light on the X_ITE bug, except to
>> indicate the error is NOT in the XML parser, to my knowledge.
>>
>>
>> I still don’t know why the non-proto expanded JSON does not
>> render properly in X_ITE. I have just figured out another bug.
>>
>> I believe the ProtoExpander error stems from IS and wanting to
>> fill in an attribute somewhere, but I’m not really sure yet. I
>> will have to check to see if the target (proto?) field is an
>> attribute or a field, I think. Hmm.
>>
>> This is probably why I had to get rid of the Proto in X3DOM, the
>> first version of the shader I released for X3DOM.
>>
>> John
>>
>> Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986>
>> for Windows 10
>>
>> *From: *John Carlson <mailto:yottzumm at gmail.com>
>> *Sent: *Tuesday, May 22, 2018 4:51 PM
>> *To: *Don Brutzman <mailto:brutzman at nps.edu>; Andreas Plesch
>> <mailto:andreasplesch at gmail.com>; holger.seelig at yahoo.de
>> <mailto:holger.seelig at yahoo.de>
>> *Subject: *RE: Bad rendering of JSON SimpleShader in X_ITE
>>
>> Note that SimpleShader.json does not pass schema with X3DJSONLD,
>> but does pass schema with my other tools. Hmm.
>>
>> You may want to try to validate against your own schema. I will
>> try against my online validator.
>>
>> John
>>
>> Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986>
>> for Windows 10
>>
>> *From: *John Carlson <mailto:yottzumm at gmail.com>
>> *Sent: *Tuesday, May 22, 2018 4:36 PM
>> *To: *Don Brutzman <mailto:brutzman at nps.edu>; Andreas Plesch
>> <mailto:andreasplesch at gmail.com>; holger.seelig at yahoo.de
>> <mailto:holger.seelig at yahoo.de>
>> *Subject: *Bad rendering of JSON SimpleShader in X_ITE
>>
>> Don, I’m not sure if this is a translation issue or an X_ITE
>> issue that the JSON displays just as Material, and doesn’t use
>> the shader. I thought you would like to be informed. I tried
>> bringing the “data:text/plain;” to be start of the source text
>> without any change to the rendering, but you may have better luck.
>>
>> You’ll need to remove ../data/ twice in the xhtml.
>>
>> This should be the original SimpleShader.x3d from sourceforge.
>>
>> It might be with data:text/plain, we have to put the entire CDATA
>> section inside a single string in JSON? I don’t know yet.
>>
>> Or maybe just remove the data:text/plain. I will try that next.
>>
>> John
>>
>> Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986>
>> for Windows 10
>>
>> *From: *John Carlson <mailto:yottzumm at gmail.com>
>> *Sent: *Tuesday, May 22, 2018 4:20 PM
>> *To: *holger.seelig at yahoo.de <mailto:holger.seelig at yahoo.de>;
>> Andreas Plesch <mailto:andreasplesch at gmail.com>
>> *Subject: *RE: [x3dom/x3dom] Full patch from
>> coderextreme/x3dom.IncludesJSONloading, protoexpander, inline
>> changes, and field changes (#844)
>>
>> Okay, it looks like there’s an issue with the JSONParser and
>> X_ITE and X3DJSONLD, possibly. See attached
>> x_itesimpleshader.xhtml for differences between JSON and XML
>> versions. I haven’t done any debugging yet, there’s probably
>> something on the console, like parsing a data URL (the shader).
>>
>> Here is the original X3D and converted JSON.
>>
>> John
>>
>> Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986>
>> for Windows 10
>>
>> *From: *John Carlson <mailto:yottzumm at gmail.com>
>> *Sent: *Tuesday, May 22, 2018 3:59 PM
>> *To: *Andreas Plesch <mailto:andreasplesch at gmail.com>
>> *Subject: *Re: [x3dom/x3dom] Full patch from coderextreme/x3dom.
>> IncludesJSONloading, protoexpander, inline changes, and field
>> changes (#844)
>>
>> Oh, okay. I guess x_ite was falling back to material in some
>> cases with X3DJSONLD. Before I started mucking with the Proto
>> from the original.
>>
>> On Tue, May 22, 2018, 3:53 PM Andreas Plesch
>> <andreasplesch at gmail.com <mailto:andreasplesch at gmail.com>> wrote:
>>
>> Thanks, the screenshot came through.
>>
>> But it looks like BSContact does not understand or use the
>> ComposedShader at all. It just falls back to the Material. I
>> think it has a console ?
>>
>> On Tue, May 22, 2018 at 3:25 PM, John Carlson
>> <yottzumm at gmail.com <mailto:yottzumm at gmail.com>> wrote:
>>
>> Hopefully this BS contact example makes it.
>>
>> ---------- Forwarded message ---------
>> From: John Carlson <yottzumm at gmail.com
>> <mailto:yottzumm at gmail.com>>
>> Date: Tue, May 22, 2018, 10:13 AM
>> Subject: RE: [x3dom/x3dom] Full patch from
>> coderextreme/x3dom. Includes JSONloading, protoexpander,
>> inline changes, and field changes (#844)
>> To: x3dom/x3dom
>> <reply+000ac4f78369c959aaa1022cea58689148651aac125ae7a492cf00000001171b6f7792a169ce1351f190 at reply.github.com
>> <mailto:reply%2B000ac4f78369c959aaa1022cea58689148651aac125ae7a492cf00000001171b6f7792a169ce1351f190 at reply.github.com>>,
>> x3dom/x3dom <x3dom at noreply.github.com
>> <mailto:x3dom at noreply.github.com>>
>> Cc: Author <author at noreply.github.com
>> <mailto:author at noreply.github.com>>
>>
>> Here it is in BS Contact:
>>
>> Sent from Mail
>> <https://go.microsoft.com/fwlink/?LinkId=550986> for
>> Windows 10
>>
>> *From: *Andreas Plesch <mailto:notifications at github.com>
>> *Sent: *Tuesday, May 22, 2018 1:41 AM
>> *To: *x3dom/x3dom <mailto:x3dom at noreply.github.com>
>> *Cc: *John Carlson <mailto:yottzumm at gmail.com>; Author
>> <mailto:author at noreply.github.com>
>> *Subject: *Re: [x3dom/x3dom] Full patch from
>> coderextreme/x3dom. Includes JSONloading, protoexpander,
>> inline changes, and field changes (#844)
>>
>> https://rawgit.com/andreasplesch/x3dom/inlineShader/doc/x3doc/base/tutorials/lighting/customShader/example.html
>> is the tutorial example.
>>
>> Here is the simpleShader.x3d for x3dom:
>> https://rawgit.com/andreasplesch/x3dom/inlineShader/test/regression-suite/test/cases/composedShader/inlineShader.xhtml
>> Do you know how it is supposed to look like ? light0 is
>> probably the headlight.
>>
>> —
>> You are receiving this because you authored the thread.
>> Reply to this email directly, view it on GitHub
>> <https://github.com/x3dom/x3dom/pull/844#issuecomment-390869376>,
>> or mute the thread
>> <https://github.com/notifications/unsubscribe-auth/AArE9_8Wd-sJSolp23LMBxXHsigHw-Weks5t06T3gaJpZM4UDkKu>.https://github.com/notifications/beacon/AArE9183osU_x9UEKTouaAfUXwpLR2Mlks5t06T3gaJpZM4UDkKu.gif
>>
>>
>>
>> --
>>
>> Andreas Plesch
>> Waltham, MA 02453
>>
>>
>>
>> ------------------------------------------------------------------------------
>> 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
>> <mailto:X3dom-users at lists.sourceforge.net>
>> https://lists.sourceforge.net/lists/listinfo/x3dom-users
>
>
> --
> *Leonard Daly*
> 3D Systems & Cloud Consultant
> LA ACM SIGGRAPH Past Chair
> President, Daly Realism - /Creating the Future/
> _______________________________________________
> x3d-public mailing list
> x3d-public at web3d.org <mailto:x3d-public at web3d.org>
> http://web3d.org/mailman/listinfo/x3d-public_web3d.org
>
>
>
> _______________________________________________
> x3d-public mailing list
> x3d-public at web3d.org
> http://web3d.org/mailman/listinfo/x3d-public_web3d.org
--
*Leonard Daly*
3D Systems & Cloud Consultant
LA ACM SIGGRAPH Past Chair
President, Daly Realism - /Creating the Future/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20180524/187044c6/attachment-0001.html>
More information about the x3d-public
mailing list