added a video player, added a GridContainer
This commit is contained in:
73
AGUI.Buttons/AGUI.TextButton3D.tscn
Normal file
73
AGUI.Buttons/AGUI.TextButton3D.tscn
Normal file
@@ -0,0 +1,73 @@
|
||||
[gd_scene format=3 uid="uid://cr5iuh28c1kuo"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://cte7rrujueh10" path="res://AgainstGravityUI/AGUI.Scripts/AGUI.Root/AGUI.TextButton3D.gd" id="1_lohaf"]
|
||||
[ext_resource type="Script" uid="uid://cbexo34ybb17a" path="res://AgainstGravityUI/AGUI.Scripts/AGUI.Collider/AGUI.Bases.Button3D.Collider.gd" id="2_wndyc"]
|
||||
|
||||
[sub_resource type="BoxShape3D" id="BoxShape3D_xeeyd"]
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_lohaf"]
|
||||
albedo_color = Color(0, 0, 0, 1)
|
||||
|
||||
[sub_resource type="Animation" id="Animation_1du0n"]
|
||||
length = 0.001
|
||||
tracks/0/type = "position_3d"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("StaticBody3D/MeshRoot")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = PackedFloat32Array(0, 1, 0, 0, 0)
|
||||
|
||||
[sub_resource type="Animation" id="Animation_xjbij"]
|
||||
resource_name = "interact"
|
||||
length = 0.1
|
||||
tracks/0/type = "position_3d"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("StaticBody3D/MeshRoot")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = PackedFloat32Array(0, 1, 0, 0, 0, 0.03333334, 1, 0, -0.05, 0)
|
||||
|
||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_7pntp"]
|
||||
_data = {
|
||||
&"RESET": SubResource("Animation_1du0n"),
|
||||
&"interact": SubResource("Animation_xjbij")
|
||||
}
|
||||
|
||||
[node name="AGUITextButton3D" type="Node3D" unique_id=81597797]
|
||||
transform = Transform3D(3.0161412, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0)
|
||||
script = ExtResource("1_lohaf")
|
||||
|
||||
[node name="StaticBody3D" type="StaticBody3D" parent="." unique_id=1473098479]
|
||||
collision_layer = 2
|
||||
collision_mask = 2
|
||||
script = ExtResource("2_wndyc")
|
||||
|
||||
[node name="Collider" type="CollisionShape3D" parent="StaticBody3D" unique_id=335334790]
|
||||
transform = Transform3D(1, 0, 0, 0, 0.011110017, 0, 0, 0, 1, 0, 0, 0)
|
||||
shape = SubResource("BoxShape3D_xeeyd")
|
||||
|
||||
[node name="MeshRoot" type="CSGCombiner3D" parent="StaticBody3D" unique_id=1112723183]
|
||||
transform = Transform3D(1, 0, 0, 0, 0.024529457, 0, 0, 0, 1, 0, 0, 0)
|
||||
material_override = SubResource("StandardMaterial3D_lohaf")
|
||||
operation = 2
|
||||
|
||||
[node name="MainMesh" type="CSGBox3D" parent="StaticBody3D/MeshRoot" unique_id=1438018078]
|
||||
|
||||
[node name="Subtractor_Box" type="CSGBox3D" parent="StaticBody3D/MeshRoot/MainMesh" unique_id=842962794]
|
||||
operation = 2
|
||||
|
||||
[node name="Subtractor_Cylinder" type="CSGCylinder3D" parent="StaticBody3D/MeshRoot/MainMesh/Subtractor_Box" unique_id=1951089581]
|
||||
transform = Transform3D(0.9, 0, 0, 0, 0.9, 0, 0, 0, 0.9, 0, 0, 0)
|
||||
operation = 2
|
||||
radius = 0.734
|
||||
|
||||
[node name="Animator" type="AnimationPlayer" parent="StaticBody3D" unique_id=53081295]
|
||||
root_node = NodePath("../..")
|
||||
libraries/ = SubResource("AnimationLibrary_7pntp")
|
||||
|
||||
[node name="Label3D" type="Label3D" parent="." unique_id=1054362994]
|
||||
transform = Transform3D(0.42440712, 0, 0, 0, -4.371139e-08, 1, 0, -1, -4.371139e-08, 0, 0.029382229, 0)
|
||||
font_size = 60
|
||||
outline_size = 0
|
||||
104
AGUI.Panels/AGUI.Popups/AGUIPopupYesNoDialog.tscn
Normal file
104
AGUI.Panels/AGUI.Popups/AGUIPopupYesNoDialog.tscn
Normal file
@@ -0,0 +1,104 @@
|
||||
[gd_scene format=3 uid="uid://b1doy05lg2drw"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://bghaddibpt6f1" path="res://addons/crt/crt.gd" id="1_1f6rs"]
|
||||
[ext_resource type="PackedScene" uid="uid://cr5iuh28c1kuo" path="res://AgainstGravityUI/AGUI.Buttons/AGUI.TextButton3D.tscn" id="2_uqna4"]
|
||||
|
||||
[sub_resource type="GDScript" id="GDScript_1f6rs"]
|
||||
resource_name = "AGUIPopupYesNoDialog"
|
||||
script/source = "@tool
|
||||
extends Node3D
|
||||
|
||||
signal yesPressed
|
||||
signal noPressed
|
||||
|
||||
@export var HeaderText : String
|
||||
@export_multiline(\"text\") var BodyText : String
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
$Header.text = HeaderText
|
||||
$Body.text = BodyText
|
||||
|
||||
func yes():
|
||||
yesPressed.emit()
|
||||
|
||||
func no():
|
||||
noPressed.emit()
|
||||
|
||||
func _ready() -> void:
|
||||
$YesButton.buttonReleased.connect(yes)
|
||||
$NoButton.buttonReleased.connect(no)
|
||||
"
|
||||
|
||||
[sub_resource type="BoxMesh" id="BoxMesh_q5w25"]
|
||||
|
||||
[sub_resource type="ViewportTexture" id="ViewportTexture_be7fk"]
|
||||
viewport_path = NodePath("ScanEffect")
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_tuti2"]
|
||||
resource_local_to_scene = true
|
||||
albedo_color = Color(1, 0.76128036, 0.41253728, 1)
|
||||
albedo_texture = SubResource("ViewportTexture_be7fk")
|
||||
|
||||
[sub_resource type="ViewportTexture" id="ViewportTexture_vkb8i"]
|
||||
viewport_path = NodePath("ScanEffect")
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_fmdwn"]
|
||||
resource_local_to_scene = true
|
||||
transparency = 1
|
||||
albedo_color = Color(0.3958079, 0.7253347, 0.9999997, 1)
|
||||
albedo_texture = SubResource("ViewportTexture_vkb8i")
|
||||
|
||||
[node name="AGUIPopupYesNoDialog" type="Node3D" unique_id=332239152]
|
||||
script = SubResource("GDScript_1f6rs")
|
||||
|
||||
[node name="Header" type="Label3D" parent="." unique_id=606928154]
|
||||
transform = Transform3D(1, 0, 0, 0, -4.371139e-08, 1, 0, -1, -4.371139e-08, 0, 0.0041175373, -0.25787705)
|
||||
pixel_size = 0.001
|
||||
render_priority = 10
|
||||
outline_render_priority = 9
|
||||
|
||||
[node name="Body" type="Label3D" parent="." unique_id=1041100711]
|
||||
transform = Transform3D(1, 0, 0, 0, -4.371139e-08, 1, 0, -1, -4.371139e-08, 0, 0.038416013, -0.19972757)
|
||||
pixel_size = 0.001
|
||||
render_priority = 10
|
||||
outline_render_priority = 9
|
||||
vertical_alignment = 0
|
||||
|
||||
[node name="ScanEffect" type="SubViewport" parent="." unique_id=783212478]
|
||||
|
||||
[node name="CanvasLayer" type="CanvasLayer" parent="ScanEffect" unique_id=1598642115]
|
||||
|
||||
[node name="CRT" type="CanvasLayer" parent="ScanEffect/CanvasLayer" unique_id=647038403]
|
||||
script = ExtResource("1_1f6rs")
|
||||
warp_amount = 0.0
|
||||
interference_amount = 0.0
|
||||
grille_amount = 0.0
|
||||
vignette_intensity = 0.094
|
||||
pixel_strength = 0.0
|
||||
metadata/_custom_type_script = "uid://bghaddibpt6f1"
|
||||
|
||||
[node name="Main" type="MeshInstance3D" parent="." unique_id=1108836209]
|
||||
transform = Transform3D(-0.9400148, 0, 0, 0, -0.008133411, 0, 0, 0, -0.71282035, 0, 0, 0)
|
||||
mesh = SubResource("BoxMesh_q5w25")
|
||||
surface_material_override/0 = SubResource("StandardMaterial3D_tuti2")
|
||||
|
||||
[node name="Overlay" type="MeshInstance3D" parent="." unique_id=706905514]
|
||||
transform = Transform3D(-0.8638695, 0, 0, 0, -0.008133411, 0, 0, 0, -0.42907837, 0, 0.009146005, 0)
|
||||
mesh = SubResource("BoxMesh_q5w25")
|
||||
surface_material_override/0 = SubResource("StandardMaterial3D_fmdwn")
|
||||
|
||||
[node name="NoButton" parent="." unique_id=81597797 instance=ExtResource("2_uqna4")]
|
||||
transform = Transform3D(0.19188501, 0, 0, 0, 0.08, 0, 0, 0, 0.08, -0.17289937, 0.01, 0.277)
|
||||
baseColor = Color(0.990877, 0.20120385, 0.2633377, 1)
|
||||
pressedColor = Color(0.72413015, 0.47285432, 7.70092e-07, 1)
|
||||
text = "No"
|
||||
|
||||
[node name="YesButton" parent="." unique_id=428776829 instance=ExtResource("2_uqna4")]
|
||||
transform = Transform3D(0.19188501, 0, 0, 0, 0.08, 0, 0, 0, 0.08, 0.16659611, 0.01, 0.277)
|
||||
baseColor = Color(0.10515302, 0.49686646, 0.71926475, 1)
|
||||
pressedColor = Color(0.72413015, 0.47285432, 7.70092e-07, 1)
|
||||
text = "Yes"
|
||||
|
||||
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="." unique_id=850774083]
|
||||
transform = Transform3D(1, 0, 0, 0, -0.018342346, 0.9998318, 0, -0.9998318, -0.018342346, 0, 0.80382794, 0)
|
||||
light_energy = 2.882
|
||||
@@ -209,7 +209,7 @@ pressedColor = Color(0.82398, 0.40454915, 0.1814934, 1)
|
||||
char = "\\"
|
||||
|
||||
[node name="Shift" parent="." unique_id=1726776584 instance=ExtResource("4_2q8pl")]
|
||||
transform = Transform3D(0.10446443, 0, 0, 0, 0.05, 0, 0, 0, 0.05, -0.39323136, 0.009753257, 0.044096336)
|
||||
transform = Transform3D(0.10446443, 0, 0, 0, 0.05, 0, 0, 0, 0.05, -0.39323136, 0.009753257, 0.032288507)
|
||||
baseColor = Color(0.30588236, 0.72156864, 1, 1)
|
||||
pressedColor = Color(0.82398, 0.40454915, 0.1814934, 1)
|
||||
char = "↑"
|
||||
@@ -409,4 +409,3 @@ char = " "
|
||||
[connection signal="buttonPressed" from="AlphaRow3/," to="." method="typeText"]
|
||||
[connection signal="buttonPressed" from="AlphaRow3/dot" to="." method="typeText"]
|
||||
[connection signal="buttonPressed" from="AlphaRow3/fslash" to="." method="typeText"]
|
||||
[connection signal="buttonPressed" from="space" to="." method="typeText"]
|
||||
|
||||
143
AGUI.Panels/AGUIWorldVideo.tscn
Normal file
143
AGUI.Panels/AGUIWorldVideo.tscn
Normal file
@@ -0,0 +1,143 @@
|
||||
[gd_scene format=3 uid="uid://dhnif8jlbhsc6"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://ivx7m2bfysip" path="res://addons/gde_gozen/video_playback.gd" id="1_uwtn7"]
|
||||
[ext_resource type="Script" uid="uid://bghaddibpt6f1" path="res://addons/crt/crt.gd" id="2_pux11"]
|
||||
[ext_resource type="PackedScene" uid="uid://cr5iuh28c1kuo" path="res://AgainstGravityUI/AGUI.Buttons/AGUI.TextButton3D.tscn" id="3_ifuim"]
|
||||
[ext_resource type="PackedScene" uid="uid://difktsmww6qlh" path="res://AgainstGravityUI/AGUI.StackedUI/AGUI.Sorting/AGUIGridContainer.tscn" id="4_m4bfe"]
|
||||
|
||||
[sub_resource type="GDScript" id="GDScript_uwtn7"]
|
||||
resource_name = "VT"
|
||||
script/source = "extends Node3D
|
||||
|
||||
@onready var PlaybackNode : VideoPlayback = $SubViewport/VideoPlayback
|
||||
@onready var sub_viewport : SubViewport = $SubViewport
|
||||
@export var URI : String
|
||||
|
||||
func _ready() -> void:
|
||||
PlaybackNode.set_video_path(URI)
|
||||
$SubViewport.render_target_update_mode = SubViewport.UPDATE_ALWAYS
|
||||
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
pass
|
||||
|
||||
func setURI(lURI):
|
||||
URI = lURI
|
||||
PlaybackNode.set_video_path(URI)
|
||||
PlaybackNode.pause()
|
||||
|
||||
|
||||
func playVideo():
|
||||
await get_tree().process_frame
|
||||
await get_tree().process_frame
|
||||
PlaybackNode.play()
|
||||
|
||||
func pauseVideo():
|
||||
PlaybackNode.pause()
|
||||
|
||||
func stopVideo():
|
||||
PlaybackNode.pause()
|
||||
PlaybackNode.seek_frame(0)
|
||||
|
||||
|
||||
# define the ID selection from CDN
|
||||
func loadVideo(ContentID:String):
|
||||
var ContentURI = \"http://{cdn}/Content/v2/{PlayerID}/{ContentID}\".format({\"cdn\":Variables.NSList[\"cdn\"], \"PlayerID\": 0, \"ContentID\": ContentID})
|
||||
setURI(ContentURI)
|
||||
"
|
||||
|
||||
[sub_resource type="ViewportTexture" id="ViewportTexture_uwtn7"]
|
||||
viewport_path = NodePath("SubViewport")
|
||||
|
||||
[sub_resource type="BoxMesh" id="BoxMesh_ifuim"]
|
||||
|
||||
[sub_resource type="ViewportTexture" id="ViewportTexture_l8nx2"]
|
||||
viewport_path = NodePath("ScanEffect")
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_m4bfe"]
|
||||
resource_local_to_scene = true
|
||||
transparency = 1
|
||||
albedo_color = Color(4.813075e-07, 0.7972619, 0.64785206, 0.80784315)
|
||||
albedo_texture = SubResource("ViewportTexture_l8nx2")
|
||||
|
||||
[node name="AGUIWorldVideo" type="Node3D" unique_id=818307991]
|
||||
script = SubResource("GDScript_uwtn7")
|
||||
|
||||
[node name="SubViewport" type="SubViewport" parent="." unique_id=330663323]
|
||||
audio_listener_enable_3d = true
|
||||
size = Vector2i(1024, 1024)
|
||||
render_target_update_mode = 4
|
||||
|
||||
[node name="VideoPlayback" type="Control" parent="SubViewport" unique_id=1060376197]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("1_uwtn7")
|
||||
metadata/_custom_type_script = "uid://ivx7m2bfysip"
|
||||
|
||||
[node name="Sprite3D" type="Sprite3D" parent="." unique_id=1814741200]
|
||||
transform = Transform3D(1.5519742, 0, 0, 0, -4.371139e-08, 1, 0, -1, -4.371139e-08, 0, 0.13255072, -0.5321164)
|
||||
render_priority = 2
|
||||
texture = SubResource("ViewportTexture_uwtn7")
|
||||
|
||||
[node name="ScanEffect" type="SubViewport" parent="." unique_id=1091330396]
|
||||
|
||||
[node name="CanvasLayer" type="CanvasLayer" parent="ScanEffect" unique_id=80462015]
|
||||
|
||||
[node name="CRT" type="CanvasLayer" parent="ScanEffect/CanvasLayer" unique_id=1329230439]
|
||||
script = ExtResource("2_pux11")
|
||||
resolution = Vector2(256, 256)
|
||||
scan_line_strength = -10.365
|
||||
warp_amount = 0.0
|
||||
noise_amount = 0.019
|
||||
interference_amount = 0.15
|
||||
grille_amount = 0.028
|
||||
vignette_amount = 0.0
|
||||
vignette_intensity = 0.094
|
||||
pixel_strength = 0.0
|
||||
metadata/_custom_type_script = "uid://bghaddibpt6f1"
|
||||
|
||||
[node name="MeshInstance3D" type="MeshInstance3D" parent="." unique_id=1139587879]
|
||||
transform = Transform3D(-16.315208, 0, 0, 0, -0.008133411, 0, 0, 0, -11.676451, 0, 0, 0)
|
||||
mesh = SubResource("BoxMesh_ifuim")
|
||||
surface_material_override/0 = SubResource("StandardMaterial3D_m4bfe")
|
||||
|
||||
[node name="AGUIMenuAnchor3D" type="Node3D" parent="." unique_id=846892698]
|
||||
transform = Transform3D(1, 0, 0, 0, 0.6469362, 0.76254416, 0, -0.76254416, 0.6469362, 2.8792367, 2.410006, 3.413855)
|
||||
|
||||
[node name="AguiGridContainer" parent="." unique_id=1053523827 instance=ExtResource("4_m4bfe")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -4.5, 0.01, 5.188)
|
||||
columns = 4
|
||||
rows = 1
|
||||
cell_size = Vector3(3, 0, 1.1)
|
||||
|
||||
[node name="Picker" parent="AguiGridContainer" unique_id=81597797 instance=ExtResource("3_ifuim")]
|
||||
transform = Transform3D(2.7014422, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0)
|
||||
baseColor = Color(1.6364455e-06, 0.38863674, 0.55388606, 1)
|
||||
pressedColor = Color(0.77477884, 0.47418594, 1.92523e-07, 1)
|
||||
text = "Picker"
|
||||
|
||||
[node name="Play" parent="AguiGridContainer" unique_id=1872940797 instance=ExtResource("3_ifuim")]
|
||||
transform = Transform3D(2.7014422, 0, 0, 0, 1, 0, 0, 0, 1, 3, 0, 0)
|
||||
baseColor = Color(1.6364455e-06, 0.38863674, 0.55388606, 1)
|
||||
pressedColor = Color(0.77477884, 0.47418594, 1.92523e-07, 1)
|
||||
text = "Play"
|
||||
|
||||
[node name="Pause" parent="AguiGridContainer" unique_id=527060119 instance=ExtResource("3_ifuim")]
|
||||
transform = Transform3D(2.7014422, 0, 0, 0, 1, 0, 0, 0, 1, 6, 0, 0)
|
||||
baseColor = Color(1.6364455e-06, 0.38863674, 0.55388606, 1)
|
||||
pressedColor = Color(0.77477884, 0.47418594, 1.92523e-07, 1)
|
||||
text = "Pause"
|
||||
|
||||
[node name="Stop" parent="AguiGridContainer" unique_id=162242037 instance=ExtResource("3_ifuim")]
|
||||
transform = Transform3D(2.7014422, 0, 0, 0, 1, 0, 0, 0, 1, 9, 0, 0)
|
||||
baseColor = Color(0.5472366, 0.1801661, 0.21535993, 1)
|
||||
pressedColor = Color(0.77477884, 0.47418594, 1.92523e-07, 1)
|
||||
text = "Stop"
|
||||
|
||||
[connection signal="buttonReleased" from="AguiGridContainer/Play" to="." method="playVideo"]
|
||||
[connection signal="buttonReleased" from="AguiGridContainer/Pause" to="." method="pauseVideo"]
|
||||
[connection signal="buttonReleased" from="AguiGridContainer/Stop" to="." method="stopVideo"]
|
||||
@@ -1,3 +1,4 @@
|
||||
@tool
|
||||
extends StaticBody3D
|
||||
|
||||
var baseColor : Color
|
||||
|
||||
@@ -15,3 +15,6 @@ signal buttonUpdated
|
||||
func _ready() -> void:
|
||||
$StaticBody3D._initButton(baseColor,pressedColor,char)
|
||||
print(baseColor,pressedColor)
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
$StaticBody3D/Label3D.text = char
|
||||
|
||||
19
AGUI.Scripts/AGUI.Root/AGUI.TextButton3D.gd
Normal file
19
AGUI.Scripts/AGUI.Root/AGUI.TextButton3D.gd
Normal file
@@ -0,0 +1,19 @@
|
||||
@tool
|
||||
extends Node3D
|
||||
|
||||
signal buttonPressed
|
||||
signal buttonReleased
|
||||
signal buttonUpdated
|
||||
|
||||
@export_category("Visuals")
|
||||
@export var baseColor : Color
|
||||
@export var pressedColor : Color
|
||||
@export var text : String
|
||||
|
||||
func _ready() -> void:
|
||||
$StaticBody3D._initButton(baseColor,pressedColor)
|
||||
print(baseColor,pressedColor)
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
$Label3D.text = text
|
||||
|
||||
1
AGUI.Scripts/AGUI.Root/AGUI.TextButton3D.gd.uid
Normal file
1
AGUI.Scripts/AGUI.Root/AGUI.TextButton3D.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://cte7rrujueh10
|
||||
78
AGUI.StackedUI/AGUI.Sorting/AGUIGridContainer.tscn
Normal file
78
AGUI.StackedUI/AGUI.Sorting/AGUIGridContainer.tscn
Normal file
@@ -0,0 +1,78 @@
|
||||
[gd_scene format=3 uid="uid://difktsmww6qlh"]
|
||||
|
||||
[sub_resource type="GDScript" id="GDScript_mjcif"]
|
||||
resource_name = "AGUIContainer"
|
||||
script/source = "@tool
|
||||
extends Node3D
|
||||
|
||||
## Number of items per row (X-axis)
|
||||
@export var columns: int = 2:
|
||||
set(value):
|
||||
columns = max(1, value)
|
||||
_sort_3d_children()
|
||||
|
||||
## Number of rows per layer (Z-axis)
|
||||
@export var rows: int = 2:
|
||||
set(value):
|
||||
rows = max(1, value)
|
||||
_sort_3d_children()
|
||||
|
||||
## Spacing between 3D objects in units
|
||||
@export var cell_size: Vector3 = Vector3(2.0, 2.0, 2.0):
|
||||
set(value):
|
||||
cell_size = value
|
||||
_sort_3d_children()
|
||||
|
||||
func _ready():
|
||||
_sort_3d_children()
|
||||
child_order_changed.connect(_sort_3d_children)
|
||||
|
||||
func _sort_3d_children():
|
||||
# 1. First pass: Gather valid Node3D children
|
||||
var 3d_children: Array[Node3D] = []
|
||||
for child in get_children():
|
||||
if child is Node3D:
|
||||
3d_children.append(child)
|
||||
|
||||
var total_items = 3d_children.size()
|
||||
if total_items == 0:
|
||||
return
|
||||
|
||||
var items_per_layer = columns * rows
|
||||
|
||||
# 2. Calculate the actual dimensions used by the current number of items
|
||||
# We use max(1, ...) to avoid multiplying by 0 if there's only 1 item
|
||||
var active_columns = min(total_items, columns)
|
||||
var active_rows = min(ceil(float(total_items) / columns), rows)
|
||||
var active_layers = ceil(float(total_items) / items_per_layer)
|
||||
|
||||
# 3. Calculate the center offset
|
||||
# (Total dimensions - 1) * cell_size / 2 gives us the exact mid-point
|
||||
var offset = Vector3(
|
||||
(active_columns - 1) * cell_size.x,
|
||||
(active_layers - 1) * cell_size.y,
|
||||
(active_rows - 1) * cell_size.z
|
||||
) * 0.5
|
||||
|
||||
# 4. Second pass: Position children and subtract the offset
|
||||
for index in range(total_items):
|
||||
var layer = index / items_per_layer
|
||||
var index_in_layer = index % items_per_layer
|
||||
var col = index_in_layer % columns
|
||||
var row = index_in_layer / columns
|
||||
|
||||
var local_pos = Vector3(
|
||||
col * cell_size.x,
|
||||
layer * cell_size.y,
|
||||
row * cell_size.z
|
||||
)
|
||||
|
||||
# Center the position relative to the parent Node3D's origin
|
||||
3d_children[index].position = local_pos - offset
|
||||
"
|
||||
|
||||
[node name="AguiGridContainer" type="Node3D" unique_id=1053523827]
|
||||
script = SubResource("GDScript_mjcif")
|
||||
columns = null
|
||||
rows = null
|
||||
cell_size = null
|
||||
Reference in New Issue
Block a user