I have spinning_top.glb aniamation which designed in blender, and iy is 3D animation but I want to shows it in 2D scene, my code and scene tree like below:
extends Node2D
# Load the GLB file as a PackedScene
var glb_scene:PackedScene = preload("res://spinning_top.glb")
# Create an instance of the scene
var glb_model:Node3D
# Create a new SubViewport
var sub_viewport = SubViewport.new()
func _ready():
# Add the SubViewport to your scene
add_child(sub_viewport)
# Instantiate the 3D model
glb_model = glb_scene.instantiate()
# Add the model to the SubViewport
sub_viewport.add_child(glb_model)
# Translate the model
glb_model.translate(Vector3(0.0, 0.0, -10.0))
# Play the animation
var animation_player = glb_model.get_node("AnimationPlayer")
if animation_player != null:
animation_player.play("ConeAction")
scene tree:
I missed what in there, project is work but I am not see spinning_top on 2D scene, any idea?
By default the content of SubViewports is not displayed. If you put the SubViewport as child of a SubViewportContainer, then the SubViewportContainer displays the SubViewport content.
I dont know how OmniLight3D or DirectionalLight3D related to animation, I adding them but sometimes object not shows sometimes shwos animation with shadow dark, by the way what is mean ETA, nad why I need an Environment?