# Toggle visibility of a group of X3D / glTF nodes

**URL:** https://forum.castle-engine.io/t/toggle-visibility-of-a-group-of-x3d-gltf-nodes/2188
**Category:** News
**Created:** [July 25, 2026, 5:37am UTC](https://forum.castle-engine.io/t/toggle-visibility-of-a-group-of-x3d-gltf-nodes/2188 "2026-07-25T05:37:01Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![michalis](https://forum.castle-engine.io/user_avatar/forum.castle-engine.io/michalis/32/3_2.png) [@michalis](https://forum.castle-engine.io/u/michalis)
#### Post date: [July 25, 2026, 5:37am UTC](https://forum.castle-engine.io/t/toggle-visibility-of-a-group-of-x3d-gltf-nodes/2188/1 "2026-07-25T05:37:01Z")

</div>

| [![Free Modular Shed with interior - model by denniswoo1993 from https://sketchfab.com/3d-models/free-modular-shed-with-interior-30b1eb71bb0e4b889160f8283e1750c1](https://forum.castle-engine.io/uploads/default/original/2X/a/abb7ce79069c93d54158238c270391609a6ad04b.png)](https://castle-engine.io/wp/wp-content/uploads/2026/07/house.png "Free Modular Shed with interior - model by denniswoo1993 from https://sketchfab.com/3d-models/free-modular-shed-with-interior-30b1eb71bb0e4b889160f8283e1750c1") |

We support now `visible` field on various [X3D nodes](https://castle-engine.io/x3d):

- `Inline` node.
  - This is `TInlineNode` when looking at the graph from Pascal.

- and on all `X3DGroupingNode` descendants, including `Transform` and `Group`.
  - These are `TAbstractGroupingNode`, `TTransformNode`, `TGroupNode` in Pascal.

We also support very similar glTF extension [KHR\_node\_visibility](https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Khronos/KHR_node_visibility). The logic of this glTF extension directly maps to X3D `visible` field.

The main use-case is to toggle visibility of a group of visual things at run-time. From Pascal code in _Castle Game Engine_, you can find the `TTransformNode` that interests you using e.g. the `TCastleSceneCore.Node` method and then toggle the `Visible` boolean property. If you don’t know what transform nodes are available (e.g. because you load model in other format, like glTF) then inspect it, by first saving it to X3D using e.g. our [Castle Model Viewer](https://castle-engine.io/castle-model-viewer), and then open X3D in any text editor.

As a testcase, open `x3d/visible_toggling.x3dv` in our demo-models repository, [https://github.com/castle-engine/demo-models/](https://github.com/castle-engine/demo-models/) . We recommend to just get the whole repository (`git clone ...`) to have all files. It shows spheres (some visible, some hidden by default) and allows toggling “visible” at runtime (using `KeySensor.controlKey` routed to “visible” fields).

For more notes see API docs on [TAbstractGroupingNode.Visible](https://castle-engine.io/apidoc/html/X3DNodes.TAbstractGroupingNode.html#Visible).

TODO:

- Both the X3D and glTF features specifications’ say to also disable light and fog nodes within a group that you made invisible. We don’t implement this yet — for now, the `Visible` field only affects the visibility of _shapes_. If you use this feature, be aware that _we will toggle lights and fog_ in the future too.

- In case of glTF, it would be great to also support [KHR\_animation\_pointer](https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Khronos/KHR_animation_pointer). This is a bit like X3D routes: allows to animate almost every part of the glTF, in particular it allows to animate the visibility defined by `KHR_node_visibility`.

If you enjoy this, please [support our work on Patreon](https://www.patreon.com/c/castleengine)!

_Our screenshot shows [house 3D model by denniswoo1993](https://sketchfab.com/3d-models/free-modular-shed-with-interior-30b1eb71bb0e4b889160f8283e1750c1). Not really related to the feature described here, just something pretty arranged in our editor:)_

---

<div class="post-metadata">

### Author: ![hal09](https://forum.castle-engine.io/letter_avatar_proxy/v4/letter/h/e9c0ed/32.png) [@hal09](https://forum.castle-engine.io/u/hal09)
#### Post date: [July 27, 2026, 8:44pm UTC](https://forum.castle-engine.io/t/toggle-visibility-of-a-group-of-x3d-gltf-nodes/2188/2 "2026-07-27T20:44:55Z")

</div>

Hi

Just sharing my method

I use TTransformNode.Scale := (0,0,0) to hide a mesh.

For example, during reload animation:  
Each weapon magazine has a bone, so I can hide the mag by setting the bone scale to (0,0,0) and build an acceptable reload animation in Pascal. At one moment I hide it and show the mag in hand, and at another moment I inverse that.

Simple and works fine. This method can also give the same result as using the Visible property.

https://www.youtube.com/embed/4Kb8MzcjW_0?feature=oembed&wmode=opaque

---

<div class="post-metadata">

### Author: ![michalis](https://forum.castle-engine.io/user_avatar/forum.castle-engine.io/michalis/32/3_2.png) [@michalis](https://forum.castle-engine.io/u/michalis)
#### Post date: [July 29, 2026, 11:13am UTC](https://forum.castle-engine.io/t/toggle-visibility-of-a-group-of-x3d-gltf-nodes/2188/3 "2026-07-29T11:13:49Z")

</div>

> [@hal09](#):
>
> This method can also give the same result as using the Visible property

That’s a cool trick:) Indeed, setting scale to zero is in many ways similar to hiding. Thought note that

- The object scaled this way is still rendered (eats rendering time). It will just “collapse” to a single point.
- Physics engine, collisions, bounding box calculations try to account for the zero-sized object. In the end, all calculations should resolve to “nothing” for such object, but these calculations are still done:)
- This also affects collisions (which may, or may not, be what someone wanted). Using X3D nodes, the more standard approach is to use TCollisionNode, which has a proxy “use this for collisions”, this allows to enable/disable/control collisions independently from visibility.
