[x3d-public] X3D/XSeen Python API (PyX3D or X3DPy)

John Carlson yottzumm at gmail.com
Tue Feb 26 20:45:40 PST 2019


Sorry for not keep you up to date, Dr. Aono, abundant apologies. Let me know if you want the the Kwargs python examples (do not compile) provided in previous post.  Here’s HelloWorld.kwargs.py (does not compile). I have stopped work on the X3DPy API implementation except to provide basic structure validation.  I will not provide rendering until we find a proper python to JavaScript implementation on top of WebGL and/or WebAssembly.  Basically, my entire effort should be 1) providing examples of X3DPy and PyX3D, 2) handling feedback. 3) providing other people with the capability to convert X3D XML to Python (and updates) 4) provide feedback to document writers.  A possible next state would be to find or develop a rendering platform for X3DPy (blender? What about the web?) for the document examples.  Do you approve Don, Vince?  Do you have any thing in the four items you want me to provide you?

Note, we’ll probably be replacing compound() with X3D things.

Please begin the branch in GitHub as we start editing the document for X3DPy.

Any other comments?  Do you like change in the API? Thanks,  I’ve been going 100% for about a day now time to relax.

Thanks,

John “The Singularity is Here, even in Iowa” Carlson

from X3Dpackage import *
X3D0 = X3D(head1 = compound([meta2 = meta(content="HelloWorld.x3d", name="title"), 
meta3 = meta(content="Simple X3D scene example: Hello World!", name="description"), 
meta4 = meta(content="30 October 2000", name="created"), 
meta5 = meta(content="14 April 2017", name="modified"), 
meta6 = meta(content="Don Brutzman", name="creator"), 
meta7 = meta(content="HelloWorld.tall.png", name="Image"), 
meta8 = meta(content="http://en.wikipedia.org/wiki/Hello_world", name="reference"), 
meta9 = meta(content="https://en.wikipedia.org/wiki/Hello#.22Hello.2C_World.22_computer_program", name="reference"), 
meta10 = meta(content="https://en.wikipedia.org/wiki/\"Hello,_World!\"_program", name="reference"), 
meta11 = meta(content="http://en.wikibooks.org/w/index.php?title=Computer_Programming/Hello_world", name="reference"), 
meta12 = meta(content="http://www.HelloWorldExample.net", name="reference"), 
meta13 = meta(content="http://www.web3D.org", name="reference"), 
meta14 = meta(content="http://www.web3d.org/realtime-3d/news/internationalization-x3d", name="reference"), 
meta15 = meta(content="http://www.web3d.org/x3d/content/examples/HelloWorld.x3d", name="reference"), 
meta16 = meta(content="http://X3dGraphics.com/examples/X3dForAdvancedModeling/HelloWorldScenes", name="reference"), 
meta17 = meta(content="http://X3dGraphics.com/examples/X3dForWebAuthors/Chapter01TechnicalOverview/HelloWorld.x3d", name="identifier"), 
meta18 = meta(content="http://www.web3d.org/x3d/content/examples/license.html", name="license"), 
meta19 = meta(content="X3D-Edit 3.3, https://savage.nps.edu/X3D-Edit", name="generator"), #  Alternate encodings: VRML97, X3D ClassicVRML Encoding, X3D Compressed Binary Encoding (CBE), X3DOM, JSON 

meta20 = meta(content="HelloWorld.wrl", name="reference"), 
meta21 = meta(content="HelloWorld.x3dv", name="reference"), 
meta22 = meta(content="HelloWorld.x3db", name="reference"), 
meta23 = meta(content="HelloWorld.xhtml", name="reference"), 
meta24 = meta(content="HelloWorld.json", name="reference")]), 
Scene25 = compound([#  Example scene to illustrate X3D nodes and fields (XML elements and attributes) 

WorldInfo26 = WorldInfo(title="Hello world!"), 
Group27 = Group(Viewpoint28 = Viewpoint(DEF="ViewUpClose", centerOfRotation=[0,-1,0], description="Hello world!", position=[0,-1,7]), 
Transform29 = Transform(Shape30 = Shape(Sphere31 = Sphere(), 
Appearance32 = Appearance(Material33 = Material(DEF="MaterialLightBlue", diffuseColor=[0.1,0.5,1]), 
ImageTexture34 = ImageTexture(DEF="ImageCloudlessEarth", url=["earth-topo.png","earth-topo.jpg","earth-topo-small.gif","http://www.web3d.org/x3d/content/examples/Basic/earth-topo.png","http://www.web3d.org/x3d/content/examples/Basic/earth-topo.jpg","http://www.web3d.org/x3d/content/examples/Basic/earth-topo-small.gif"]))), rotation=[0,1,0,3]), 
Transform35 = Transform(Shape36 = Shape(Text37 = Text(FontStyle38 = FontStyle(justify=["MIDDLE","MIDDLE"]), DEF="TextMessage", string=["Hello","world!"]), 
Appearance39 = Appearance(Material40 = Material(USE="MaterialLightBlue"))), translation=[0,-2,0]]), profile="Immersive", version="3.3")
X3D0.toFileX3D("/x3d-code/www.web3d.org/x3d/stylesheets/java/src/python/pythonapi/data/HelloWorld.newf.x3d")


Sent from Mail for Windows 10

From: John Carlson
Sent: Tuesday, February 26, 2019 9:40 PM
To: vpython-users at googlegroups.com; Don Brutzman; Vincent Marchetti; Leonard Daly; Jeffry Hysong
Subject: X3D/XSeen Python API (PyX3D or X3DPy)

Here are more examples of where Web3D’s Python X3D API (PyX3D) going, based on your input. Jeffry, time to look at the python in the attached zip and comment on the API (it doesn’t run yet, we’re creating a standard (read design document) for the API first, not the implementation. Jeffry, is there an extension to PyOpenGL to do PyWebGL? Please work with Leonard if he agrees to pick the “best” PyWebGL solution. All: discuss whether API is dependent on X3D V4 or not.  I don’t think it should be based on competing platforms.  PyX3D should be able to use ALL python 3D graphics APIs I believe.  Whether I can do that as a newbie python programmer is questionable.

Thanks.

1. Started using the compound([]) def.   Couldn’t get it to work right with Group or Transform yet.  Discuss use of Transform versus “children” below. Suggest deprecating compound().
2. Still have a lot of “extra” def’s that haven’t been mapped to compound yet.  Plan to use HTML5 attributes and continue to flatten X3D hierarchy, but may not be needed with “children” keyword. Examples need to be looked at for “children” keyword possibilities. Right now, it looks like we can inline a bunch of stuff
3. Need to revisit DEF/USE to create extra parent links in scene group (or use “children” or variables)
Attached.  Not nicely formatted (sorry).  Probably not legal python yet.

Latest API examples uses kwargs in Python for  handing non-positional parameters. New API not generated yet. Need to look at standards for using kwargs.

We need to discuss use of transform attributes within X3DShape instances, perhaps.    Seems more natural for expert 3D graphics API users to want separated (not multiplied transforms, but multiplication could be added by API when rendering, instead of when building.  Seems a fundamental approach difference that may not be handled. Don, Vince, Jeffry, ideas?

There seems to be a use case for using functions in declarative code, “declarative functional”, although that’s not apparent.  Perhaps we could spend some time converting vpython’s code over to declarative code with his approval of examples chosen, and the physics tags, and presenting it back to Bruce for acceptance into vpython.  Why don’t people buy into a heavy weight framework (when heavy weight means verbose and directed acyclic graph), but then use a translator to convert python to JavaScript to just to get web? Is JavaScript this wonderfully secure thing that will never get repeated in the history of the web?  Or is python the anti-web? I think they better cut that slogan pretty fast now. It looks like JavaScript and Web Assembly are becoming target architectures for python.

I know of PBR (physics based rendering) which may be of interest to Bruce as a physicist. What could we offer Bruce as a physicist to work on enhancing his API with optional features for the support of X3D? I know there’s a lot of Physics components in X3D.  Can we show them off in python with Bruce’s help?

Perhaps we should set our requirements for the Python API?
1. WebGL/OpenGL (possibly implemented in JavaScript)
2. Do not use JavaScript’s eval().  I don’t know about python’s yet.
3. Web-based
4. Python 3.X
5. Jupyter notebooks
6. 3D objects (from which profiles?)
7. Declarative, Hierarchical Transforms
8. Animation of scenegraph within API, Create, Read, Update, Delete nodes
9. Metadata

The only thing that seems  to be missing on the surface from vpython is declarative, hierarchical transforms, and possibly metadata.

I have yet to look at the previously mentioned pythonocc.
http://www.pythonocc.org/

Which uses X3DOM. I don’t really want to write another python to JavaScript converter (lets grab one).
There appear to be plenty out there for the web.  Best of breed solutions accepted, along with X3D requirements met.  What are our requirements for a python to JavaScript converter?  Do we need to support such a beast to get Jupyter?    Can you see my ECMAScript colors flying? Should we create a task for analyzing all the “python to javascript converters”? Leonard, can you do this under the auspices of XSeen, or is it “too slow” “not enterprise acceptable” “not standardizable”?

>From what I’ve seen so far, these tools use JavaScript eval() and not new Function() for getting JavaScript code into the browser.  That would be one requirement. Do not use eval().

Don, can you add the requirements to the web3d wiki yet?

Next step: Finalize Python API.  Finish analysis of existing 3D APIs, including Panda3D we need a feature comparison comparing all Python 3D APIs.  Get feedback from Bruce (thanks for your previous input. Noted), Jeffry and Leonard. Leonard, do you want to be included in standardizing this Python API for XSeen?  Can we formalize an Python standard for both X3D and XSeen (and other APIs, including PyJNIus X3DJSAIL)?  Going along the lines that everything is going to be included in the Semantic Models anyway? Do we need to include versions in the Semantic Models?

Whither PyOpenInventor?

Will PyX3D become become the future of X3D? Even with this JavaScript bulge attached to it?
Progress:

1. Have Kwargs version of PythonSerializer.
2. Have one version back API generator, need to update per vpython API.

John
Sent from Mail for Windows 10

From: Bruce Sherwood
Sent: Tuesday, February 26, 2019 10:50 AM
To: VPython-users
Subject: Re: Exporting VPython objects to STL (or other 3D file formats)

Again, this highly verbose code would seem to be approximately equivalent to the following very brief VPython code:

label(text="Hello world!", pos=vec(0,1,0)) # I put the text above the 3D earth
s = sphere(pos=vec(0,-2,0), texture=textures.earth)
s.rotate(angle=pi/4, axis=vec(0,1,0)) # not sure of the meaning of rotation=[0,1,0,3], so I give an example

Please explain what connection your project has to VPython and its goal of serving users who need not be highly expert in 3D graphics. The only connection I'm able to glimpse is that it could perhaps be used somehow for creating tools for import of sophisticated 3D models to VPython programs, and/or for export of 3D models generated by VPython programs. Neither import nor export facilities currently exist for VPython (except for the rudimentary STL example).

Bruce
-- 
You received this message because you are subscribed to the Google Groups "VPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vpython-users+unsubscribe at googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20190226/31e195c6/attachment-0001.html>


More information about the x3d-public mailing list