[x3d-public] X3DPSAIL x3d.py package updated and deployed to x3d.py, adding initial support for JSON export
John Carlson
yottzumm at gmail.com
Mon Dec 6 00:15:39 PST 2021
With some flimflamming around, I was able to clear up some of my
previous stacktraces. Now I'm stuck in JSON export, may switch to XML
export:
Traceback (most recent call last):
File "/c/x3d-code/www.web3d.org/x3d/content/examples/x3dinput.py",
line 148, in <module>
print(scene.JSON(indentLevel=0, syntax="JSON"))
File "/c/x3d-code/www.web3d.org/x3d/content/examples/x3d.py", line
12792, in JSON
result += str(self.Scene.JSON(indentLevel=indentLevel+1,
syntax=syntax))
File "/c/x3d-code/www.web3d.org/x3d/content/examples/x3d.py", line
12303, in JSON
result += each.JSON(indentLevel=indentLevel+1, syntax=syntax)
TypeError: JSON() got an unexpected keyword argument 'indentLevel'
A similar error appeared in several places, and I got rid of the
arguments, plus I removed the 100 character limit on one exception in
this diff:
diff /c/x3d-code/www.web3d.org/x3d/stylesheets/python/x3d.py x3d.py
3206c3206
< raise X3DTypeError(str(value)[:100] + ' element ' +
str(each) + ', type=' + str(type(each)) + ' is not a valid _X3DNode or
_X3DStatement fo
r MFNode')
---
> raise X3DTypeError(str(value) + ' element ' + str(each) +
', type=' + str(type(each)) + ' is not a valid _X3DNode or _X3DStatement
for MFNo
de')
12303c12303
< result += each.JSON(indentLevel=indentLevel+1,
syntax=syntax)
---
> result += str(each.JSON())
42407c42407
< result += each.JSON(indentLevel=indentLevel+1,
syntax=syntax)
---
> result += each.JSON()
77412c77412
< result +=
self.geometry.JSON(indentLevel=indentLevel+1, syntax=syntax)
---
> result += self.geometry.JSON()
89062c89062
< result += each.JSON(indentLevel=indentLevel+1,
syntax=syntax)
---
> result += each.JSON()
I was able to stumble through to get some JSON output, but I don't
particularly parse the whole input yet. Code is attached, much more
work is needed, but at least this sample input is starting to see the
light of day!
To run, unpack the zip, and run $ python3 x3dinput.py
A local HelloWorld.json is the default input in the zip. Perhaps we
can discuss the progress tomorrow at 4pm? I've already noticed some
issues, but I will try to get to bed tonight. I have a lot more
confidence in my ability to at least create a sample JSON import
module/package. I'm a bit concerned that neither @version nor @profile
were output. More work is needed on JSON Export. There are a few things
I see in the JSON export, like multiple "meta" objects, and SFVec3f
being strings instead of arrays. I will like get to geometry and
appearance in the next few days.
{
"X3D":
{ "head":
{ "meta":
{
"@content":"HelloWorld.x3d",
"@name":"title"
}
},
{ "meta":
{
"@content":"Simple X3D model example: Hello World!",
"@name":"description"
}
},
{ "meta":
{
"@content":"30 October 2000",
"@name":"created"
}
},
{ "meta":
{
"@content":"11 June 2021",
"@name":"modified"
}
},
{ "meta":
{
"@content":"Don Brutzman",
"@name":"creator"
}
},
{ "meta":
{
"@content":"HelloWorld.tall.png",
"@name":"Image"
}
},
{ "meta":
{
"@content":"https://en.wikipedia.org/wiki/Hello_world",
"@name":"reference"
}
},
{ "meta":
{
"@content":"https://en.wikipedia.org/wiki/Hello#.22Hello.2C_World.22_computer_program",
"@name":"reference"
}
},
{ "meta":
{
"@content":"https://en.wikipedia.org/wiki/"Hello,_World!"_program",
"@name":"reference"
}
},
{ "meta":
{
"@content":"https://en.wikibooks.org/w/index.php?title=Computer_Programming/Hello_world",
"@name":"reference"
}
},
{ "meta":
{
"@content":"https://www.HelloWorldExample.net",
"@name":"reference2"
}
},
{ "meta":
{
"@content":"https://www.web3d.org",
"@name":"reference"
}
},
{ "meta":
{
"@content":"https://www.web3d.org/realtime-3d/news/internationalization-x3d",
"@name":"reference"
}
},
{ "meta":
{
"@content":"https://www.web3d.org/x3d/content/examples/HelloWorld.x3d",
"@name":"reference"
}
},
{ "meta":
{
"@content":"https://X3dGraphics.com/examples/X3dForAdvancedModeling/HelloWorldScenes/HelloWorld.x3d",
"@name":"reference"
}
},
{ "meta":
{
"@content":"https://X3dGraphics.com/examples/X3dForWebAuthors/Chapter01TechnicalOverview/HelloWorld.x3d",
"@name":"identifier"
}
},
{ "meta":
{
"@content":"https://www.web3d.org/x3d/content/examples/license.html",
"@name":"license"
}
},
{ "meta":
{
"@content":"X3D-Edit 4.0, https://savage.nps.edu/X3D-Edit",
"@name":"generator"
}
},
{ "meta":
{
"@content":"HelloWorld.wrl",
"@name":"reference"
}
},
{ "meta":
{
"@content":"HelloWorld.x3dv",
"@name":"reference"
}
},
{ "meta":
{
"@content":"HelloWorld.x3db",
"@name":"reference"
}
},
{ "meta":
{
"@content":"HelloWorld.xhtml",
"@name":"reference"
}
},
{ "meta":
{
"@content":"HelloWorld.json",
"@name":"reference"
}
},
{ "meta":
{
"@content":"14 October 2021",
"@name":"translated"
}
},
{ "meta":
{
"@content":"X3dToJson.xslt,
https://www.web3d.org/x3d/stylesheets/X3dToJson.html",
"@name":"generator"
}
},
{ "meta":
{
"@content":"X3D JSON encoding:
https://www.web3d.org/wiki/index.php/X3D_JSON_Encoding",
"@name":"reference"
}
},
}
{ "Scene":
None{ "WorldInfo":
{
"@info":""Example scene to illustrate a simple X3D model"",
"@title":"Hello World!"
}
}
{ "Group":
{ "Viewpoint":
{
"@DEF":"ViewUpClose",
"@centerOfRotation":"0 -1 0",
"@description":"Hello world!",
"@position":"0 -1 7"
}
},
{ "Transform":
{ "Shape":
{ "Appearance":
},
}
}
{ "Transform":
{ "Shape":
{ "Appearance":
},
}
}
}
}
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20211206/30f965ac/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: JSONImport.zip
Type: application/zip
Size: 380840 bytes
Desc: not available
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20211206/30f965ac/attachment-0001.zip>
More information about the x3d-public
mailing list