[x3d-public] x3d.py Re: Tree-to-tree transformation
Joe D Williams
joedwil at earthlink.net
Wed Aug 2 12:56:39 PDT 2023
Hi All,
It is not a tree, it is a DAG, directed acyclic graph, which is much more fun than a tree.
Yes, the x3d HAnim structures and accessories can be a tree, but a DAG is so much more fun.
A tree is so, not quite x3d.
Joe
-----Original Message-----
From: John Carlson <yottzumm at gmail.com>
Sent: Aug 2, 2023 12:51 PM
To: GPU Group <gpugroup at gmail.com>, X3D Graphics public mailing list <x3d-public at web3d.org>
Subject: Re: [x3d-public] x3d.py Re: Tree-to-tree transformation
The JSON parser/loader is part of Python, so if you use it, fewer problems will happen, as you say. There are VRML parsers/loaders in each VRML supporting browser. I think X_ITE/x3d-tidy has one. I’m just trying to get one loader working, and my current choice is python program synthesis. Ugh! I guess i could write something that instantiates x3d instances with eval. I’ve always heard that eval is a “bad thing,” but I’ve used it in a pinch.
John
On Wed, Aug 2, 2023 at 2:28 PM GPU Group <gpugroup at gmail.com (mailto:gpugroup at gmail.com)> wrote:
I haven't seen any import functions in x3d.py. The code isn't too hard to read. I think import is harder than export, because there are so many things that can be wrong with an import file, and it's not 1:1. But exporting --once you have a clean scenegraph-- is easy.I think the default brute force way to import is to load a file into its native tree -- html into an html tree, json into a json tree (like we load glTF), x3d into an xml tree. There are standard loaders for those. Is there a loader like that for vrml/classic/x3dv?
Then traverse that tree and convert to x3d.py nodes as you go.
-Doug
Here's another example code of a standalone program using x3d.py I was working on recently.
https://freewrl.sourceforge.io/tests/43_MIDI/88key/OLD/keyboard_gen_x3dpy.py
- which shows a few more examples of the syntax x3d.py needs.
- program didn't work due to hard thing: a ProtoInstance with SFNode in an MFNode fieldvalue. Hypotheses: H0: I'm not using the right syntax for x3d.py in that case H1: x3d.py has a bug.
- But generally works pretty good once you figure out the syntax, class names, fields etc.
On Wed, Aug 2, 2023 at 1:00 PM John Carlson <yottzumm at gmail.com (mailto:yottzumm at gmail.com)> wrote:
I am thinking about X3d.py design.
I was not aware if x3d.py had any input, clarification?
I’m trying to read this:
https://www.web3d.org/x3d/stylesheets/python/python.html
It would seem appropriate to have a core X3D abstract python model, call it the python object model or POM, and then add what i call python “view,” “presentation,” or “encoding” models for XML, JSON, X3DOM, VRML, and X_ITE …input/output, perhaps generated by more than one stylesheet. I think stuffing the encodings into one package is not the right design. We should follow the standards way of separating abstract architecture from encoding and binding.
I would propose stylesheets for each encoding, just like we have for converting XML to various encodings, X3dTo….xslt.
What’s the counter argument?
I welcome any discussion, this is kind of the monolithic kernel versus microkernel idea i realize. Monolithic won.
This is also along the lines of HTMLElement, SVGElement, Node, and Element in ECMAScript.
You can still stuff it all in the same x3d.py file, one can also support XML(), VRML() methods on the abstract model that defer or delegate to encoding models. I don’t think anything breaks.
Is this somehow un-pythonic?
John
On Wed, Aug 2, 2023 at 1:21 PM John Carlson <yottzumm at gmail.com (mailto:yottzumm at gmail.com)> wrote:
Does anyone know good tools for tree-to-tree transformation? I know ANTLR and XML/XSL/XSLT. I guess this is pretty much a compiler task. Are there tools for Classic VRML and JSON? Python/Perl/ECMAScrpt?
John
_______________________________________________
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 (mailto:x3d-public at web3d.org)
http://web3d.org/mailman/listinfo/x3d-public_web3d.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20230802/cc9ab947/attachment.html>
More information about the x3d-public
mailing list