[x3d-public] Python API

John Carlson yottzumm at gmail.com
Tue Feb 26 06:54:52 PST 2019


Here’s an example of a possible Python API for X3D.   Comments besides lack of lines?   I  hand edited this to remove 1) a lack of lists/arrays. 2) duplicated kwargs (same problem as JSON, we have to insert an array/list/object into the kwargs to contain a list/object around the common keys.

What would your idea Python API for X3D look like?    A call with a dict in it sending it to the X3D subsystem (totally declarative)?  Why or why not?

How should PROTOs be handled in Python?     Comments?

How do people like looking at YAT (yet another take) on X3D? Is it more like VRML, X3D or JSON?

Are we improving the API by making it less Java-like?

What interested animation and event handling and data binding opportunities grant us?

Comments from others working on Python APIs (thanks in advance).

Can we start on a stylesheet converter from XML based on this example? (I know it’s not HelloWorld, but I’m the JavaScript/PROTO guy, and it’s basically the first file translated in my bunch.) HelloWorld will come next.

Too many ()’s? Almost feels like LISP? Certainly we could remove the parentheses around the objects.

Thanks,

John



from X3Dpackage import *
X3D0 = X3D(profile="Immersive", version="3.3", Head = (head(
       Meta = [(meta(name="title", content="abox.x3d")),
       (meta(name="creator", content="John Carlson")),
       (meta(name="generator", content="manual")),
       (meta(name="identifier", content="https://coderextreme.net/X3DJSONLD/abox.x3d")),
       (meta(name="description", content="a box"))))],
       Scene = (Scene(Children = [
       (ProtoDeclare(name="anyShape",
       ProtoInterface = (ProtoInterface(Field = (field(type = field.TYPE_MFNODE, name="myShape",
       accessType=field.ACCESSTYPE_INPUTOUTPUT, Child = (Shape(geometry = (Sphere()))))))),
       ProtoBody = (ProtoBody(Child = (Transform(IS = (IS(Connect = (connect(nodeField="children", protoField="myShape")))))))))),
(ProtoDeclare(name="one",
       ProtoInterface = (ProtoInterface(Field = (field(type = field.TYPE_MFNODE, name="myShape",
       accessType=field.ACCESSTYPE_INPUTOUTPUT, Child = (Shape(geometry = (Cylinder()))))))),
       ProtoBody = (ProtoBody(Child = (Transform(Child =
       (ProtoInstance(name="anyShape", IS = (IS(Connect = (connect(nodeField="myShape", protoField="myShape")))))))))))),
 (ProtoInstance(name="one", FieldValue = (fieldValue(name="myShape", Child = (Shape(geometry = (Box(size=[140,140,140]))))))])))))
X3D0.toFileX3D("/x3d-code/www.web3d.org/x3d/stylesheets/java/src/python/pythonapi/data/abox.newf.x3d")
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20190226/809d7023/attachment.html>


More information about the x3d-public mailing list