[x3d-public] Question: Geometry class for x3d.py?

John Carlson yottzumm at gmail.com
Tue Dec 7 08:19:29 PST 2021


Updated x3dinput.py attached.

Proceeded with eval, removed JSON_Geometry class.

There is no need for a x3d.py Geometry class that I know of, except for 
below.

Regexp still needed for security purposes (no constructing arbitrary, 
possibly hidden classes, please).

Looks good, not sure of performance at this time, we could provide 
factory, dispatch table, switch, or if/elif/else for constructing 
geometry.   Eval seems the least secure.  Perhaps we could run some 
benchmarks?

"DOM" API for creating scenegraph "elements" seems like a good solution.

Please provide direction for desired implementation.  If we continue 
with eval, perhaps we could apply it in more places?

Enjoy JSON parsing HelloWorld.json!

John

On 12/7/21 09:58, John Carlson wrote:
>
> Don, you may want to create a Geometry class in x3d.py like:
>
> classGeometry(_X3DGeometryNode):
> defFIELD_DECLARATIONS(cls):
> return[]
> defJSON(self):
> returnself.geometry.JSON();
> defXML(self):
> returnself.geometry.XML();
>
>
> Also, we would have to provide parsers to fill in self.geometry.
>
> Or test for self.geometry in the JSON and XML methods, or add a 
> constructor.
>
> This is mainly for loading the -geometry field.
>
> It could be handled in the Shape class, with eval() figuring out which 
> geometry constructor to call.  That is okay with me!
>
> Obviously, eval is a tiny bit dangerous, even if only resolving a 
> class.  I recommend creating a regexp that matches all node and 
> statement names.
>
> I'm going to proceed with eval in the Shape class for now.
>
> Thanks!
>
> John
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20211207/f32e046d/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: JSONImport4.zip
Type: application/zip
Size: 3129 bytes
Desc: not available
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20211207/f32e046d/attachment-0001.zip>


More information about the x3d-public mailing list