[x3d-public] cyclic
GPU Group
gpugroup at gmail.com
Sun Mar 29 14:28:07 PDT 2026
Thanks Michalis.
-Doug
Would a bit flag on a node work?
- tested for false before starting node.draw()
- then set to true when starting node.draw()
- then set to false when ending node.draw()
For the script field reference to an ancestor, the script isn't drawing the
node, so bit flag wouldn't be tested.
On Sun, Mar 29, 2026 at 3:14 PM Michalis Kamburelis <
michalis at castle-engine.io> wrote:
> 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
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20260329/8bab52a8/attachment.html>
More information about the x3d-public
mailing list