[x3d-public] X3DPSAIL x3d.py package updated and deployed to x3d.py, adding initial support for JSON export

John Carlson yottzumm at gmail.com
Sun Dec 5 23:15:59 PST 2021


On 12/6/21 00:41, John Carlson wrote:
>
>
> On 12/6/21 00:29, John Carlson wrote:
>>
>>
>> On 12/6/21 00:19, John Carlson wrote:
>>>
>>> Don, I will probably begin working on JSON export testing after I 
>>> take the JSON import example for a short spin.  It's good to get a 
>>> code download.
>>>
>>> Note that SFVec3f should put a tuple in the structure when parsing 
>>> JSON...normal JSON does not include tuples, so there needs to be a 
>>> type conversion.
>>>
>>> That is, centerOfRotation and position in Viewpoint should be 
>>> tuples, not lists as JSON provides.
>>>
>> Fixed as far as I am concerned right now.  I will try to remove my 
>> tuple soon.
> Tested removing tuple() without any problems.

Further problems (previously found, but hidden) indicated using tuple() 
solved problems, so I put the tuple for SFVec3f back in.

Working on further problems:

Traceback (most recent call last):
  File "/c/x3d-code/www.web3d.org/x3d/content/examples/x3dinput.py", 
line 141, in <module>
    scene = newscene.parseJSON(data["X3D"])
  File "/c/x3d-code/www.web3d.org/x3d/content/examples/x3dinput.py", 
line 12, in parseJSON
    self.Scene.parseJSON(data["Scene"])
  File "/c/x3d-code/www.web3d.org/x3d/content/examples/x3dinput.py", 
line 28, in parseJSON
    self.children.parseJSON(data)
  File "/c/x3d-code/www.web3d.org/x3d/content/examples/x3dinput.py", 
line 131, in parseJSON
    sfnode.parseJSON(c)
  File "/c/x3d-code/www.web3d.org/x3d/content/examples/x3dinput.py", 
line 121, in parseJSON
    self.value.parseJSON(data[key])
  File "/c/x3d-code/www.web3d.org/x3d/content/examples/x3dinput.py", 
line 55, in parseJSON
    self.children.parseJSON(data)
  File "/c/x3d-code/www.web3d.org/x3d/content/examples/x3dinput.py", 
line 131, in parseJSON
    sfnode.parseJSON(c)
  File "/c/x3d-code/www.web3d.org/x3d/content/examples/x3dinput.py", 
line 121, in parseJSON
    self.value.parseJSON(data[key])
  File "/c/x3d-code/www.web3d.org/x3d/content/examples/x3dinput.py", 
line 63, in parseJSON
    self.children = self.children.value
  File "/c/x3d-code/www.web3d.org/x3d/content/examples/x3d.py", line 
88922, in children
    assertValidMFNode(children)
  File "/c/x3d-code/www.web3d.org/x3d/content/examples/x3d.py", line 
3206, in assertValidMFNode
    raise X3DTypeError(str(value)[:100] + ' element ' + str(each) + ', 
type=' + str(type(each)) + ' is not a valid _X3DNode or _X3DStatement 
for MFNode')
  File "/c/x3d-code/www.web3d.org/x3d/content/examples/x3d.py", line 
4448, in __str__
    return self.__repl__()
  File "/c/x3d-code/www.web3d.org/x3d/content/examples/x3d.py", line 
4446, in __repl__
    return str(self.value)
  File "/c/x3d-code/www.web3d.org/x3d/content/examples/x3d.py", line 
7950, in __str__
    return self.__repl__().strip() # X3DNode
  File "/c/x3d-code/www.web3d.org/x3d/content/examples/x3d.py", line 
7945, in __repl__
    result += str(name) + '='       + str(value)[:100]       + ','
  File "/c/x3d-code/www.web3d.org/x3d/content/examples/x3d.py", line 
7950, in __str__
    return self.__repl__().strip() # X3DNode
  File "/c/x3d-code/www.web3d.org/x3d/content/examples/x3d.py", line 
7921, in __repl__
    if self.FIELD_DECLARATIONS():
AttributeError: 'JSON_Geometry' object has no attribute 'FIELD_DECLARATIONS'

I'm not convinced that this JSON_Geometry class should exist, I just 
added it for parsing. It looks like this:


class JSON_Geometry(_X3DGeometryNode):
    def parseJSON(self, data):
        return self

Not much yet.  But yeah, it looks like inspection of x3d.py does not 
reveal a specific FIELD_DECLARATIONS variable in the superclasses?   
Maybe I should just inherit from object?  I will try that.

Whew!

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20211206/63e3daec/attachment.html>


More information about the x3d-public mailing list