[x3d-public] What is allowed in MFNode (classic encoding) changed in X3D 4.0, my notes and testcase

Michalis Kamburelis michalis.kambi at gmail.com
Mon Oct 30 06:50:14 PDT 2023


Hi,

It seems that, despite my recommendation not to do so, the X3D classic
encoding was changed to enable EXTERNPROTO/PROTO/ROUTE in the middle
of MFNode in classic encoding. Previously they could only be placed
within a node (any node naturally), but not inside MFNode [ ...]
brackets.

I don't have an exact spec text of the change (it is not public, I
don't have Mantis access), but I guess from the Don's comments in
https://github.com/castle-engine/view3dscene/issues/79 that classic
encoding formal grammar was changed to effectively make
"nodeStatement" the same as "statement" (using terms from
https://www.web3d.org/documents/specifications/19776-2/V3.3/Part02/grammar.html
).

This does cause some challenging cases for software processing X3D,
e.g. if you try to read and then write X3D and then read back the
result. The order is sometimes critical, as nodes and prototypes may
use each other, and now they can be mixed within MFNode list.

This is an example testcase:
https://github.com/castle-engine/demo-models/blob/master/x3d/routes_protos_within_mfnode.x3dv
. Feel free to use it.

CGE/view3dscene now read it correctly, and have correct round-trip
(i.e. you can write the nodes to X3D classic file, then read it back).
It's not perfect implementation and probably never will be (to be
perfect, we'd have to store the order in MFNode of everything,
effectively making MFNode field not a "list of nodes" but a "list of
anything").

There's also another interesting exception now, because PROTO default
value can be MFNode too, and that one naturally can have only nodes,
not EXTERNPROTO or ROUTEs. I don't know how the updated spec has
actually addressed it.  You can see the details I'm talking about in
https://github.com/castle-engine/demo-models/blob/master/x3d/routes_protos_within_mfnode.x3dv#L69
, i.e. the default value of "defaultContents" inside
"ProtoBasedOnBlueConeTransform".

Hopefully this testcase will help others to implement this new tricky
case of spec.

Regards,
Michalis



More information about the x3d-public mailing list