[x3d-public] cyclic
Michalis Kamburelis
michalis at castle-engine.io
Sun Mar 29 14:13:57 PDT 2026
On Sunday, March 29th, 2026 at 20:02, GPU Group via x3d-public <x3d-public at web3d.org> wrote:
> There doesn't seem to be anything to stop a scene from being cyclic -- freewrl has no defense against it, and simply crashes likely from stack overflow.-Doug
The X3D specification does say your example (Group containing itself) is invalid:
https://www.web3d.org/documents/specifications/19775-1/V4.0/Part01/concepts.html
Ctrl+F "acyclic" :)
"""An X3D scene graph is a directed acyclic graph"""
"""The transformation hierarchy shall be a directed acyclic graph; a node in the transformation hierarchy that is its own ancestor is considered invalid and shall be ignored. The following is an example of a node in the scene graph that is its own ancestor:..."""
On a browser side, we indeed must put special care to not allow it. One option is to add to the "maintained mapping" the name->node only once the node is fully finished.
Note that _some_ way of having cycles in a typical OOP implementation are still possible, e.g. Script field may refer to a parent node of this script. CGE handles it using "weak links", to avoid a loop in ref counting. This makes applying the above advise ("add to the "maintained mapping" the name->node only once the node is fully finished...") not so straightforward, you need to have a mapping to resolve references to current parents too.
https://github.com/castle-engine/demo-models/blob/master/x3d/node_cycle_in_script.x3dv
https://github.com/castle-engine/demo-models/blob/master/x3d/node_cycle_in_script.x3d
Regards,
Michalis
More information about the x3d-public
mailing list