[X3D-Public] [x3dom-developers] initial X3D JSON conversion support using X3dToJson.xslt

Cecile Muller newsletter at wildpeaks.fr
Fri Oct 17 07:13:21 PDT 2014


Hi Don,


> Something that jumps out is when you say "How would you make a Group that
contains a Shape, a Transform and another Shape ?
> It can't be the following because an Object can't define property Shape
twice".
>
> That is indeed a serious constraint, if it is indeed correct - that
wasn't clear about Javascript. (got a reference?)

Imagine this Javascript code:

var myobj = {
"value": 1,
"value": 2,
"value": 3
};

What would you expect the value of "myobj.value" to be ?
Maybe it's 1, maybe it's 3 (most likely), maybe it's neither because it
threw an exception because the property is already defined.

Regardless of the result, some of the information get lost; therefore if
something needs multiple values, it's safer to use an Array instead.



> Wondering then, what about your repeated use of "_type", isn't that the
same sort of repetition as repeating "Shape" and "Transform" ?

Using property "Shape" would require an extra Object between the Array and
the object that contains the shape fields to be able to use a key/value
pair.

Longer reply with code samples:
https://github.com/wildpeaks/json-scenegraph/issues/3



> wondering then whether this slight variation using field name
(containerField) is an alternative option:
>     "_children": "Shape"
>     ...
> },
> {
>    "_children": "Transform"
>    ...
> },
> {
>    "_children": "Shape"

It would have two downsides:
 - SFNode gets written a different way based on where it is in the
scenegraph
 - you can't know the list of nodes in a given field unless you parse the
whole list of nodes

Longer reply with code samples:
https://github.com/wildpeaks/json-scenegraph/issues/4


See you,
Cecile
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20141017/1b7b8b99/attachment.html>


More information about the X3D-Public mailing list