From b2e9bbfe0112f17cf847964343f5211a8c4e3586 Mon Sep 17 00:00:00 2001 From: Aaron Franke Date: Mon, 6 Oct 2025 11:12:26 -0700 Subject: [PATCH] GLTF: Support animating node visibility --- modules/gltf/gltf_document.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/modules/gltf/gltf_document.cpp b/modules/gltf/gltf_document.cpp index 7ea1fec1195..de5b931363c 100644 --- a/modules/gltf/gltf_document.cpp +++ b/modules/gltf/gltf_document.cpp @@ -6420,6 +6420,7 @@ void GLTFDocument::_generate_scene_node(Ref p_state, const GLTFNodeIn // Note: p_scene_parent and p_scene_root must either both be null or both be valid. _set_node_tree_owner(current_node, p_scene_root); current_node->set_transform(gltf_node->transform); + current_node->set_visible(gltf_node->visible); current_node->merge_meta_from(*gltf_node); p_state->scene_nodes.insert(p_node_index, current_node); for (int i = 0; i < gltf_node->children.size(); ++i) { @@ -6890,6 +6891,14 @@ Ref GLTFDocument::import_object_model_property(Refappend_path_to_property(node_path, "visible"); + ret->set_types(Variant::BOOL, GLTFObjectModelProperty::GLTF_OBJECT_MODEL_TYPE_BOOL); + } } } else if (split[0] == "cameras") { const String &camera_prop = split[2]; @@ -7197,7 +7206,7 @@ Ref GLTFDocument::export_object_model_property(Ref(target_object)) { split_json_pointer.append("nodes"); @@ -7219,6 +7228,11 @@ Ref GLTFDocument::export_object_model_property(Refset_types(Variant::TRANSFORM3D, GLTFObjectModelProperty::GLTF_OBJECT_MODEL_TYPE_FLOAT4X4); + } else if (target_prop == "visible") { + split_json_pointer.append("extensions"); + split_json_pointer.append("KHR_node_visibility"); + split_json_pointer.append("visible"); + ret->set_types(Variant::BOOL, GLTFObjectModelProperty::GLTF_OBJECT_MODEL_TYPE_BOOL); } else { split_json_pointer.clear(); }