visualisation-marsh/project/aircraft/aircraft.gd
attila-vr 4ddccdaf62 Redo main scene
Much simpler XR setup based on Bastiaan Olij's Dev stream 58
Correctly applied bone deformation in Mi-2 model
2025-02-18 11:34:59 +01:00

19 lines
671 B
GDScript

extends Node3D
@onready var connector = $MarshConnector
@onready var skeleton = $"Mi-2/Armature/Skeleton3D"
@onready var attitude_root = $AttitudeRoot
@onready var bone_cg: int = skeleton.find_bone("BodyCG")
func _process(_delta: float) -> void:
var target: Transform3D = connector.get_aircraft()
position = target.origin
# Add the rotation to the bone
var rest = skeleton.get_bone_rest(bone_cg).basis.get_rotation_quaternion()
var attitude = target.basis.get_rotation_quaternion()
skeleton.set_bone_pose_rotation(bone_cg, attitude * rest)
# Rotate other children (not using BoneAttachment3D due to jitter)
attitude_root.rotation = target.basis.get_euler()