Commit dd43f717 authored by Gavin An's avatar Gavin An

작업 중

parent 06984fd9
[gd_resource type="ShaderMaterial" load_steps=4 format=3 uid="uid://el5y10hnh13g"]
[gd_resource type="ShaderMaterial" format=3 uid="uid://el5y10hnh13g"]
[ext_resource type="Shader" uid="uid://dce675i014xcn" path="res://addons/terrain_3d/extras/particle_example/particles.gdshader" id="1_t55me"]
......@@ -8,8 +8,8 @@ frequency = 0.0145
cellular_return_type = 4
[sub_resource type="NoiseTexture2D" id="NoiseTexture2D_544iv"]
seamless = true
noise = SubResource("FastNoiseLite_544iv")
seamless = true
[resource]
shader = ExtResource("1_t55me")
......
[gd_scene load_steps=8 format=3 uid="uid://cofnhdcclon1w"]
[gd_scene format=3 uid="uid://cofnhdcclon1w"]
[ext_resource type="Script" path="res://demo/src/CodeGenerated.gd" id="1_h7vyv"]
[ext_resource type="Script" uid="uid://dakis6gu8b7nm" path="res://demo/src/CodeGenerated.gd" id="1_h7vyv"]
[ext_resource type="PackedScene" uid="uid://domhm87hbhbg1" path="res://demo/components/Player.tscn" id="2_3v2uf"]
[ext_resource type="PackedScene" uid="uid://bb2lp50sjndus" path="res://demo/components/Environment.tscn" id="3_71ikj"]
[ext_resource type="PackedScene" uid="uid://di5fovhcyd7re" path="res://demo/components/Enemy.tscn" id="4_p8qry"]
[ext_resource type="PackedScene" uid="uid://d2jihfohphuue" path="res://demo/components/UI.tscn" id="4_x5ge4"]
[ext_resource type="Script" path="res://demo/src/RuntimeNavigationBaker.gd" id="5_445ur"]
[ext_resource type="Script" uid="uid://brh8x1wnycrl5" path="res://demo/src/RuntimeNavigationBaker.gd" id="5_445ur"]
[sub_resource type="NavigationMesh" id="NavigationMesh_vs6am"]
geometry_parsed_geometry_type = 1
agent_height = 2.0
agent_max_slope = 30.0
[node name="CodeGenerated" type="Node"]
[node name="CodeGenerated" type="Node" unique_id=241546107]
script = ExtResource("1_h7vyv")
[node name="Environment" parent="." instance=ExtResource("3_71ikj")]
[node name="Environment" parent="." unique_id=399881060 instance=ExtResource("3_71ikj")]
[node name="Player" parent="." instance=ExtResource("2_3v2uf")]
[node name="Player" parent="." unique_id=947092461 instance=ExtResource("2_3v2uf")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 50, 0)
[node name="Enemy" parent="." node_paths=PackedStringArray("target") instance=ExtResource("4_p8qry")]
[node name="Enemy" parent="." unique_id=470570682 node_paths=PackedStringArray("target") instance=ExtResource("4_p8qry")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 10, 50, -10)
target = NodePath("../Player")
[node name="UI" parent="." instance=ExtResource("4_x5ge4")]
[node name="UI" parent="." unique_id=1439217852 instance=ExtResource("4_x5ge4")]
[node name="RuntimeNavigationBaker" type="Node" parent="." node_paths=PackedStringArray("player")]
[node name="RuntimeNavigationBaker" type="Node" parent="." unique_id=67681880 node_paths=PackedStringArray("player")]
script = ExtResource("5_445ur")
enabled = false
template = SubResource("NavigationMesh_vs6am")
player = NodePath("../Player")
[node name="RunThisSceneLabel3D" type="Label3D" parent="."]
[node name="RunThisSceneLabel3D" type="Label3D" parent="." unique_id=323616349]
pixel_size = 0.001
billboard = 1
no_depth_test = true
......
[gd_scene load_steps=10 format=3 uid="uid://djhl3foqkj4e2"]
[gd_scene format=3 uid="uid://djhl3foqkj4e2"]
[ext_resource type="PackedScene" uid="uid://be6nrf0b8j4l0" path="res://demo/assets/models/RockA.tscn" id="1_m1xck"]
[ext_resource type="PackedScene" uid="uid://bwvtgwartxt0g" path="res://demo/assets/models/RockB.tscn" id="2_hybky"]
......@@ -12,150 +12,150 @@
[sub_resource type="BoxShape3D" id="BoxShape3D_goiy4"]
size = Vector3(530.482, 38.6343, 235.603)
[node name="Tunnel" type="Node3D"]
[node name="Tunnel" type="Node3D" unique_id=11008120]
[node name="EntranceL" type="Node3D" parent="."]
[node name="EntranceL" type="Node3D" parent="." unique_id=430416080]
[node name="RockA1" parent="EntranceL" instance=ExtResource("1_m1xck")]
[node name="RockA1" parent="EntranceL" unique_id=1607580258 instance=ExtResource("1_m1xck")]
transform = Transform3D(5.82988, -5.4374, -4.00004, 6.04396, 6.55839, -0.106264, 3.00604, -2.64109, 7.9713, 807.937, 137.298, 467.411)
[node name="RockA2" parent="EntranceL" instance=ExtResource("1_m1xck")]
[node name="RockA2" parent="EntranceL" unique_id=73710992 instance=ExtResource("1_m1xck")]
transform = Transform3D(4.67905, 4.22076, -5.5926, 6.98724, -3.31022, 3.34764, -0.52024, -6.49718, -5.3387, 766.019, 104.95, 452.605)
[node name="RockA3" parent="EntranceL" instance=ExtResource("1_m1xck")]
[node name="RockA3" parent="EntranceL" unique_id=435955825 instance=ExtResource("1_m1xck")]
transform = Transform3D(1.19782, 11.0889, 4.42738, -11.9291, 0.921057, 0.9205, 0.510788, -4.49312, 11.1153, 793.166, 76.9378, 454.834)
[node name="RockB1" parent="EntranceL" instance=ExtResource("2_hybky")]
[node name="RockB1" parent="EntranceL" unique_id=1305215111 instance=ExtResource("2_hybky")]
transform = Transform3D(-2.10522, -4.25988, 3.15298, 3.05166, -3.74811, -3.02637, 4.33304, 0.570028, 3.66329, 824.574, 112.54, 446.946)
[node name="RockB3" parent="EntranceL" instance=ExtResource("2_hybky")]
[node name="RockB3" parent="EntranceL" unique_id=2072825766 instance=ExtResource("2_hybky")]
transform = Transform3D(4.29222, 4.57142, 1.24961, -2.49948, 3.61605, -4.6432, -4.02641, 2.62846, 4.21447, 773.937, 140.911, 469.972)
[node name="RockC1" parent="EntranceL" instance=ExtResource("3_nbn1a")]
[node name="RockC1" parent="EntranceL" unique_id=835184053 instance=ExtResource("3_nbn1a")]
transform = Transform3D(-1.86839, -3.85072, -1.99813, -0.0474326, -2.1573, 4.20181, -4.33801, 1.6821, 0.814656, 786.081, 135.376, 453.531)
[node name="RockC2" parent="EntranceL" instance=ExtResource("3_nbn1a")]
[node name="RockC2" parent="EntranceL" unique_id=1639684135 instance=ExtResource("3_nbn1a")]
transform = Transform3D(-3.90856, -4.56077, 3.35866, 3.81036, 0.902037, 5.65911, -4.19074, 5.07383, 2.01294, 791.859, 164.408, 508.107)
[node name="EntranceR" type="Node3D" parent="."]
[node name="EntranceR" type="Node3D" parent="." unique_id=809682812]
[node name="RockA1" parent="EntranceR" instance=ExtResource("1_m1xck")]
[node name="RockA1" parent="EntranceR" unique_id=1181749987 instance=ExtResource("1_m1xck")]
transform = Transform3D(-0.271255, 1.28607, -2.97471, -1.25761, 2.70942, 1.28605, 2.98685, 1.25759, 0.271335, 299.644, 127.203, 424.309)
[node name="RockA2" parent="EntranceR" instance=ExtResource("1_m1xck")]
[node name="RockA2" parent="EntranceR" unique_id=1346849968 instance=ExtResource("1_m1xck")]
transform = Transform3D(2.29164, -2.44454, 3.0731, 3.84134, 0.657286, -2.34167, 0.814771, 3.77671, 2.39666, 318.179, 95.8599, 421.731)
[node name="RockA5" parent="EntranceR" instance=ExtResource("1_m1xck")]
[node name="RockA5" parent="EntranceR" unique_id=90367231 instance=ExtResource("1_m1xck")]
transform = Transform3D(1.09929, -4.37397, 0.575562, 3.84134, 0.657286, -2.34167, 2.16957, 1.05247, 3.85443, 321.814, 95.8599, 436.931)
[node name="RockA3" parent="EntranceR" instance=ExtResource("1_m1xck")]
[node name="RockA3" parent="EntranceR" unique_id=1974272870 instance=ExtResource("1_m1xck")]
transform = Transform3D(3.70822, 1.86229, 1.85804, 2.19079, -0.408409, -3.96295, -1.45634, 4.12752, -1.23046, 338.177, 116.66, 430.367)
[node name="RockA4" parent="EntranceR" instance=ExtResource("1_m1xck")]
[node name="RockA4" parent="EntranceR" unique_id=140628868 instance=ExtResource("1_m1xck")]
transform = Transform3D(1.9779, 0.270409, 4.08487, -4.00125, 1.0869, 1.86547, -0.865577, -4.40646, 0.710812, 320.977, 134.583, 441.012)
[node name="RockB1" parent="EntranceR" instance=ExtResource("2_hybky")]
[node name="RockB1" parent="EntranceR" unique_id=1117631552 instance=ExtResource("2_hybky")]
transform = Transform3D(-1.64956, -1.63286, 1.75857, 0.196316, 2.03499, 2.07367, -2.39171, 1.29322, -1.04267, 295.848, 109.828, 419.45)
[node name="RockB3" parent="EntranceR" instance=ExtResource("2_hybky")]
[node name="RockB3" parent="EntranceR" unique_id=135710830 instance=ExtResource("2_hybky")]
transform = Transform3D(-2.03718, 1.29729, 2.88404, -2.82928, 0.784888, -2.35156, -1.41272, -3.44263, 0.550663, 306.288, 128.712, 434.042)
[node name="RockB4" parent="EntranceR" instance=ExtResource("2_hybky")]
[node name="RockB4" parent="EntranceR" unique_id=1880069677 instance=ExtResource("2_hybky")]
transform = Transform3D(1.97436, 2.87133, -1.41708, -2.82928, 0.784888, -2.35156, -1.49926, 2.30004, 2.57153, 328.686, 129.709, 427.63)
[node name="RockB2" parent="EntranceR" instance=ExtResource("2_hybky")]
[node name="RockB2" parent="EntranceR" unique_id=568102744 instance=ExtResource("2_hybky")]
transform = Transform3D(-2.17746, 0.476253, -1.87396, -1.61495, 1.104, 2.15708, 1.06324, 2.65221, -0.561397, 303.461, 107.797, 428.826)
[node name="RockC1" parent="EntranceR" instance=ExtResource("3_nbn1a")]
[node name="RockC1" parent="EntranceR" unique_id=560689946 instance=ExtResource("3_nbn1a")]
transform = Transform3D(1.74949, 1.15588, 0.576742, -1.01213, 1.82987, -0.597152, -0.802676, 0.21197, 2.01002, 335.27, 110.419, 418.362)
[node name="RockC2" parent="EntranceR" instance=ExtResource("3_nbn1a")]
[node name="RockC2" parent="EntranceR" unique_id=1709813106 instance=ExtResource("3_nbn1a")]
transform = Transform3D(4.31956, 5.88829, -1.29353, -3.67086, 1.30662, -6.31041, -4.78226, 4.31561, 3.67549, 345.465, 146.581, 480.747)
[node name="TunnelMesh" parent="." instance=ExtResource("4_klbpo")]
[node name="TunnelMesh" parent="." unique_id=1429448742 instance=ExtResource("4_klbpo")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 546.733, 112.043, 468.686)
[node name="CrystalGroup1" type="Node3D" parent="."]
[node name="CrystalGroup1" type="Node3D" parent="." unique_id=2145808430]
transform = Transform3D(0.567756, 0.0788585, -0.00345403, 0.0729824, -0.514888, 0.241124, 0.0300693, -0.239266, -0.520024, 415.722, 122.719, 611.385)
[node name="CrystalC" parent="CrystalGroup1" instance=ExtResource("5_bb2w0")]
[node name="CrystalC" parent="CrystalGroup1" unique_id=626542899 instance=ExtResource("5_bb2w0")]
transform = Transform3D(0.990472, -0.134216, 0.0307963, 0.132893, 0.873058, -0.469155, 0.0360812, 0.468779, 0.882577, 0.050354, 1.72128, 4.54956)
[node name="CrystalC3" parent="CrystalGroup1" instance=ExtResource("5_bb2w0")]
[node name="CrystalC3" parent="CrystalGroup1" unique_id=870006944 instance=ExtResource("5_bb2w0")]
transform = Transform3D(0.999999, 2.98023e-08, 0, 1.40402e-08, 0.999999, 1.19209e-07, 6.89635e-09, -1.49012e-07, 0.999999, 4.00897, 3.69431, -0.617554)
[node name="CrystalC2" parent="CrystalGroup1" instance=ExtResource("5_bb2w0")]
[node name="CrystalC2" parent="CrystalGroup1" unique_id=698149431 instance=ExtResource("5_bb2w0")]
transform = Transform3D(-0.513116, -0.374576, 0.95887, -0.130632, 1.08641, 0.354495, -1.02111, 0.0492404, -0.527189, -1.70374, 4.03528, -0.568237)
[node name="OmniLight3D" type="OmniLight3D" parent="CrystalGroup1"]
[node name="OmniLight3D" type="OmniLight3D" parent="CrystalGroup1" unique_id=397042778]
transform = Transform3D(1, 3.21278e-08, -1.96807e-08, -3.21278e-08, 1, 1.02499e-07, 1.96807e-08, -1.02499e-07, 1, 1.11737, 4.79865, 1.8949)
light_color = Color(0.4, 0.760784, 1, 1)
light_energy = 16.0
shadow_enabled = true
omni_range = 83.054
[node name="CrystalGroup2" type="Node3D" parent="."]
[node name="CrystalGroup2" type="Node3D" parent="." unique_id=93433741]
transform = Transform3D(-0.536793, -0.0213862, -0.199931, -0.116106, 0.498308, 0.25843, 0.164163, 0.282504, -0.470976, 553.318, 103.571, 647.425)
[node name="CrystalC" parent="CrystalGroup2" instance=ExtResource("5_bb2w0")]
[node name="CrystalC" parent="CrystalGroup2" unique_id=2012220497 instance=ExtResource("5_bb2w0")]
transform = Transform3D(0.704558, -0.579782, 0.130258, 0.554941, 0.56972, -0.465804, 0.212495, 0.434496, 0.784585, 0.815979, 1.24854, 2.5437)
[node name="Rock3" parent="CrystalGroup2/CrystalC" index="0"]
[node name="Rock3" parent="CrystalGroup2/CrystalC" index="0" unique_id=1287173055]
surface_material_override/0 = ExtResource("6_s6twx")
[node name="CrystalC3" parent="CrystalGroup2" instance=ExtResource("5_bb2w0")]
[node name="CrystalC3" parent="CrystalGroup2" unique_id=1982998581 instance=ExtResource("5_bb2w0")]
transform = Transform3D(0.127208, -0.0568556, -1.06836, -0.317718, 1.02534, -0.0923969, 1.02161, 0.32596, 0.104294, 4.00861, 3.69458, -0.617188)
[node name="Rock3" parent="CrystalGroup2/CrystalC3" index="0"]
[node name="Rock3" parent="CrystalGroup2/CrystalC3" index="0" unique_id=1287173055]
surface_material_override/0 = ExtResource("6_s6twx")
[node name="CrystalC2" parent="CrystalGroup2" instance=ExtResource("5_bb2w0")]
[node name="CrystalC2" parent="CrystalGroup2" unique_id=892629221 instance=ExtResource("5_bb2w0")]
transform = Transform3D(-0.642172, -0.213226, 0.774009, 0.484154, 0.687794, 0.591163, -0.640428, 0.733767, -0.329203, 7.28876, 1.71277, 4.52783)
[node name="Rock3" parent="CrystalGroup2/CrystalC2" index="0"]
[node name="Rock3" parent="CrystalGroup2/CrystalC2" index="0" unique_id=1287173055]
surface_material_override/0 = ExtResource("6_s6twx")
[node name="OmniLight3D" type="OmniLight3D" parent="CrystalGroup2"]
[node name="OmniLight3D" type="OmniLight3D" parent="CrystalGroup2" unique_id=183672878]
transform = Transform3D(1.74454, 2.98023e-08, -2.98023e-08, -5.60482e-08, 1.74454, 1.49012e-07, 3.43338e-08, -1.78814e-07, 1.74454, 1.11737, 4.79865, 1.8949)
light_color = Color(0.396078, 0.333333, 0.878431, 1)
light_energy = 16.0
shadow_enabled = true
omni_range = 83.054
[node name="CrystalGroup3" type="Node3D" parent="."]
[node name="CrystalGroup3" type="Node3D" parent="." unique_id=153952614]
transform = Transform3D(-0.536793, -0.0213862, -0.199931, 0.0789312, -0.546626, -0.153451, -0.184932, -0.17123, 0.514837, 711.291, 124.136, 579.252)
[node name="CrystalC" parent="CrystalGroup3" instance=ExtResource("5_bb2w0")]
[node name="CrystalC" parent="CrystalGroup3" unique_id=250464080 instance=ExtResource("5_bb2w0")]
transform = Transform3D(0.898105, -0.188271, 0.0864646, 0.196692, 0.654036, -0.618921, 0.0650697, 0.621535, 0.677476, 0.589844, 2.22089, 3.04785)
[node name="Rock3" parent="CrystalGroup3/CrystalC" index="0"]
[node name="Rock3" parent="CrystalGroup3/CrystalC" index="0" unique_id=1287173055]
surface_material_override/0 = ExtResource("7_7fkm2")
[node name="CrystalC3" parent="CrystalGroup3" instance=ExtResource("5_bb2w0")]
[node name="CrystalC3" parent="CrystalGroup3" unique_id=1533298290 instance=ExtResource("5_bb2w0")]
transform = Transform3D(0.15544, 0.0752453, -1.06348, -0.370935, 1.01139, 0.0173435, 0.999527, 0.363637, 0.171821, 4.00867, 3.69458, -0.617432)
[node name="Rock3" parent="CrystalGroup3/CrystalC3" index="0"]
[node name="Rock3" parent="CrystalGroup3/CrystalC3" index="0" unique_id=1287173055]
surface_material_override/0 = ExtResource("7_7fkm2")
[node name="CrystalC2" parent="CrystalGroup3" instance=ExtResource("5_bb2w0")]
[node name="CrystalC2" parent="CrystalGroup3" unique_id=1205867364 instance=ExtResource("5_bb2w0")]
transform = Transform3D(-0.573134, -0.100696, 0.847536, 0.285048, 0.939695, 0.304405, -0.804489, 0.404691, -0.495942, 7.2887, 1.71283, 4.52771)
[node name="Rock3" parent="CrystalGroup3/CrystalC2" index="0"]
[node name="Rock3" parent="CrystalGroup3/CrystalC2" index="0" unique_id=1287173055]
surface_material_override/0 = ExtResource("7_7fkm2")
[node name="OmniLight3D" type="OmniLight3D" parent="CrystalGroup3"]
[node name="OmniLight3D" type="OmniLight3D" parent="CrystalGroup3" unique_id=996275763]
transform = Transform3D(1.74454, 2.98023e-08, -2.98023e-08, -5.60482e-08, 1.74454, 1.49012e-07, 3.43338e-08, -1.78814e-07, 1.74454, 1.11737, 4.79865, 1.8949)
light_color = Color(0.388235, 0.101961, 0.2, 1)
light_energy = 16.0
shadow_enabled = true
omni_range = 83.054
[node name="CaveArea3D" type="Area3D" parent="."]
[node name="CaveArea3D" type="Area3D" parent="." unique_id=1266152989]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 549.961, 110.763, 526.656)
collision_mask = 2
script = ExtResource("9_fn2ke")
[node name="CollisionShape3D" type="CollisionShape3D" parent="CaveArea3D"]
[node name="CollisionShape3D" type="CollisionShape3D" parent="CaveArea3D" unique_id=1987319103]
transform = Transform3D(0.998441, 0, -0.0558215, 0, 1, 0, 0.0558215, 0, 0.998441, -8.36676, 3.78637, 30.7709)
shape = SubResource("BoxShape3D_goiy4")
......
[gd_resource type="Terrain3DAssets" load_steps=11 format=3 uid="uid://dal3jhw6241qg"]
[gd_resource type="Terrain3DAssets" format=3 uid="uid://dal3jhw6241qg"]
[ext_resource type="PackedScene" uid="uid://bn5nf4esciwex" path="res://demo/assets/models/LODExample.tscn" id="1_4jrdu"]
[ext_resource type="Texture2D" uid="uid://c88j3oj0lf6om" path="res://demo/assets/textures/rock023_alb_ht.png" id="2_pog6b"]
......
......@@ -8,6 +8,10 @@ func _enter_tree() -> void:
if GameManager.selected_stage_map_path != "":
map_path = GameManager.selected_stage_map_path
_load_stage_background(map_path)
_load_stage_map(map_path)
func _load_stage_map(map_path: String) -> void:
var map_scene: PackedScene = load(map_path) as PackedScene
if map_scene:
var map_inst: Node = map_scene.instantiate()
......@@ -20,3 +24,26 @@ func _enter_tree() -> void:
push_error("Main: NavigationRegion3D not found.")
else:
push_error("Main: Failed to load map scene: " + map_path)
func _load_stage_background(map_path: String) -> void:
var background_path: String = _get_background_path_for_map(map_path)
if background_path == "":
return
var background_scene: PackedScene = load(background_path) as PackedScene
if not background_scene:
push_error("Main: Failed to load background scene: " + background_path)
return
var background_inst: Node = background_scene.instantiate()
background_inst.name = "StageBackground"
add_child(background_inst)
func _get_background_path_for_map(map_path: String) -> String:
match map_path:
"res://src/map/stages/stage_1_map.tscn":
return "res://src/map/background/desert.tscn"
"res://src/map/stages/stage_2_map.tscn":
return "res://src/map/background/swamp.tscn"
_:
return ""
......@@ -4,23 +4,6 @@ extends Camera3D
## RTS 스타일 탑다운 3D 카메라 컨트롤러
## 키보드(WASD) 및 마우스 경계 스크롤로 평면을 이동하고 마우스 휠로 줌 조작이 가능합니다.
# 이동 및 줌 속도 설정
@export var move_speed: float = 25.0
@export var zoom_speed: float = 10.0
@export var zoom_step: float = 2.0
# 줌 범위 설정
@export var min_zoom: float = 5.0
@export var max_zoom: float = 15.0
# 화면 가장자리 마우스 감지 여백 (픽셀 단위)
@export var edge_margin: float = 15.0
@export var enable_edge_scroll: bool = true
# 맵 카메라 이동 한계 설정 (바닥 크기 20x20 기준)
@export var limit_min: Vector2 = Vector2(-8.0, -8.0)
@export var limit_max: Vector2 = Vector2(8.0, 8.0)
# 현재 카메라가 바라보고 있는 바닥의 포커스 좌표 (이곳을 중심으로 회전 및 줌이 일어남)
var _target_focus: Vector3 = Vector3.ZERO
var _current_zoom: float = 10.0
......@@ -31,86 +14,83 @@ func _ready() -> void:
# pitch 각도를 60도로 설정 (main.tscn 기본값)
var angle_rad: float = deg_to_rad(60.0)
# 초기 줌 레벨을 최대 줌 아웃(max_zoom, 가장 축소된 뷰) 상태로 설정
_current_zoom = max_zoom
_target_zoom = _current_zoom
# Z 오프셋 = Y / tan(60) 이므로, 포커스 타겟 Z = 카메라 Z - Z 오프셋
var z_offset: float = _current_zoom / tan(angle_rad)
_target_focus = Vector3(global_position.x, 0.0, global_position.z - z_offset)
# 초기 셋업 적용
_update_camera_transform(0.0)
_update_camera_transform(60)
func _physics_process(delta: float) -> void:
pass
# 1. 입력 방향 계산
var direction: Vector3 = _get_input_direction()
#var direction: Vector3 = _get_input_direction()
# 줌아웃이 최대치(max_zoom) 근처일 때는 카메라 이동을 차단하고 맵 중앙으로 초점을 부드럽게 복구
var is_max_zoom: bool = _target_zoom >= (max_zoom - 0.1)
#var is_max_zoom: bool = _target_zoom >= (max_zoom - 0.1)
# 2. 포커스 타겟 이동
if is_max_zoom:
_target_focus = _target_focus.lerp(Vector3.ZERO, delta * move_speed * 0.2)
elif direction != Vector3.ZERO:
_target_focus += direction * move_speed * delta
_target_focus.x = clampf(_target_focus.x, limit_min.x, limit_max.x)
_target_focus.z = clampf(_target_focus.z, limit_min.y, limit_max.y)
#if is_max_zoom:
#_target_focus = _target_focus.lerp(Vector3.ZERO, delta * move_speed * 0.2)
#elif direction != Vector3.ZERO:
#_target_focus += direction * move_speed * delta
#_target_focus.x = clampf(_target_focus.x, limit_min.x, limit_max.x)
#_target_focus.z = clampf(_target_focus.z, limit_min.y, limit_max.y)
# 3. 줌 레벨 선형 보간
if not is_equal_approx(_current_zoom, _target_zoom):
_current_zoom = lerpf(_current_zoom, _target_zoom, delta * zoom_speed)
# 4. 카메라 위치 및 회전 업데이트
_update_camera_transform(delta)
#if not is_equal_approx(_current_zoom, _target_zoom):
#_current_zoom = lerpf(_current_zoom, _target_zoom, delta * zoom_speed)
#
## 4. 카메라 위치 및 회전 업데이트
#_update_camera_transform(delta)
func _unhandled_input(event: InputEvent) -> void:
pass
# 마우스 휠을 통한 줌 조작
if event is InputEventMouseButton:
var mouse_event: InputEventMouseButton = event as InputEventMouseButton
if mouse_event.is_pressed():
if mouse_event.button_index == MOUSE_BUTTON_WHEEL_UP:
_target_zoom = clampf(_target_zoom - zoom_step, min_zoom, max_zoom)
elif mouse_event.button_index == MOUSE_BUTTON_WHEEL_DOWN:
_target_zoom = clampf(_target_zoom + zoom_step, min_zoom, max_zoom)
#if event is InputEventMouseButton:
#var mouse_event: InputEventMouseButton = event as InputEventMouseButton
#if mouse_event.is_pressed():
#if mouse_event.button_index == MOUSE_BUTTON_WHEEL_UP:
#_target_zoom = clampf(_target_zoom - zoom_step, min_zoom, max_zoom)
#elif mouse_event.button_index == MOUSE_BUTTON_WHEEL_DOWN:
#_target_zoom = clampf(_target_zoom + zoom_step, min_zoom, max_zoom)
## 입력 방향 계산 (키보드 WASD/방향키 + 마우스 경계 스크롤)
func _get_input_direction() -> Vector3:
var dir: Vector3 = Vector3.ZERO
# 키보드 입력 체크
if Input.is_key_pressed(KEY_A) or Input.is_action_pressed("ui_left"):
dir.x -= 1.0
if Input.is_key_pressed(KEY_D) or Input.is_action_pressed("ui_right"):
dir.x += 1.0
if Input.is_key_pressed(KEY_W) or Input.is_action_pressed("ui_up"):
dir.z -= 1.0
if Input.is_key_pressed(KEY_S) or Input.is_action_pressed("ui_down"):
dir.z += 1.0
#func _get_input_direction() -> Vector3:
#var dir: Vector3 = Vector3.ZERO
## 키보드 입력 체크
#if Input.is_key_pressed(KEY_A) or Input.is_action_pressed("ui_left"):
#dir.x -= 1.0
#if Input.is_key_pressed(KEY_D) or Input.is_action_pressed("ui_right"):
#dir.x += 1.0
#if Input.is_key_pressed(KEY_W) or Input.is_action_pressed("ui_up"):
#dir.z -= 1.0
#if Input.is_key_pressed(KEY_S) or Input.is_action_pressed("ui_down"):
#dir.z += 1.0
# 마우스 경계 스크롤 체크
if enable_edge_scroll:
var viewport: Viewport = get_viewport()
if viewport:
var mouse_pos: Vector2 = viewport.get_mouse_position()
var viewport_size: Vector2 = viewport.get_visible_rect().size
# 마우스 포인터가 화면 크기 안에 있을 때만 스크롤 수행 (창 밖 이탈 방지)
if mouse_pos.x >= 0.0 and mouse_pos.y >= 0.0 and mouse_pos.x <= viewport_size.x and mouse_pos.y <= viewport_size.y:
if mouse_pos.x < edge_margin:
dir.x -= 1.0
elif mouse_pos.x > viewport_size.x - edge_margin:
dir.x += 1.0
if mouse_pos.y < edge_margin:
dir.z -= 1.0
elif mouse_pos.y > viewport_size.y - edge_margin:
dir.z += 1.0
## 마우스 경계 스크롤 체크
#if enable_edge_scroll:
#var viewport: Viewport = get_viewport()
#if viewport:
#var mouse_pos: Vector2 = viewport.get_mouse_position()
#var viewport_size: Vector2 = viewport.get_visible_rect().size
#
## 마우스 포인터가 화면 크기 안에 있을 때만 스크롤 수행 (창 밖 이탈 방지)
#if mouse_pos.x >= 0.0 and mouse_pos.y >= 0.0 and mouse_pos.x <= viewport_size.x and mouse_pos.y <= viewport_size.y:
#if mouse_pos.x < edge_margin:
#dir.x -= 1.0
#elif mouse_pos.x > viewport_size.x - edge_margin:
#dir.x += 1.0
#if mouse_pos.y < edge_margin:
#dir.z -= 1.0
#elif mouse_pos.y > viewport_size.y - edge_margin:
#dir.z += 1.0
return dir.normalized()
#return dir.normalized()
## 카메라의 Position과 Rotation을 업데이트
func _update_camera_transform(_delta: float) -> void:
# 피치 각도 60도 고정
var angle_rad: float = deg_to_rad(60.0)
var angle_rad: float = deg_to_rad(_delta)
var z_offset: float = _current_zoom / tan(angle_rad)
# 카메라 글로벌 좌표 설정
......
[gd_scene format=3 uid="uid://bqtcnfyfplvsr"]
[sub_resource type="Gradient" id="Gradient_dc7hf"]
offsets = PackedFloat32Array(0.2, 1)
colors = PackedColorArray(1, 1, 1, 1, 0, 0, 0, 1)
[sub_resource type="FastNoiseLite" id="FastNoiseLite_11m5b"]
noise_type = 2
frequency = 0.03
cellular_jitter = 3.0
cellular_return_type = 0
domain_warp_enabled = true
domain_warp_type = 1
domain_warp_amplitude = 50.0
domain_warp_fractal_type = 2
domain_warp_fractal_lacunarity = 1.5
domain_warp_fractal_gain = 1.0
[sub_resource type="NoiseTexture2D" id="NoiseTexture2D_htwul"]
noise = SubResource("FastNoiseLite_11m5b")
color_ramp = SubResource("Gradient_dc7hf")
seamless = true
[sub_resource type="Terrain3DMaterial" id="Terrain3DMaterial_1of3m"]
_shader_parameters = {
&"bias_distance": null,
&"blend_sharpness": null,
&"depth_blur": null,
&"enable_macro_variation": null,
&"enable_projection": null,
&"flat_terrain_normals": null,
&"macro_variation1": null,
&"macro_variation2": null,
&"macro_variation_slope": null,
&"mipmap_bias": null,
&"noise1_angle": null,
&"noise1_offset": null,
&"noise1_scale": null,
&"noise2_scale": null,
&"noise_texture": SubResource("NoiseTexture2D_htwul"),
&"projection_threshold": null
}
show_checkered = true
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_8t5t6"]
transparency = 4
cull_mode = 2
vertex_color_use_as_albedo = true
backlight_enabled = true
backlight = Color(0.5, 0.5, 0.5, 1)
distance_fade_mode = 1
distance_fade_min_distance = 128.0
distance_fade_max_distance = 96.0
[sub_resource type="Terrain3DMeshAsset" id="Terrain3DMeshAsset_o05ja"]
generated_type = 1
height_offset = 0.5
material_override = SubResource("StandardMaterial3D_8t5t6")
last_lod = 0
last_shadow_lod = 0
lod0_range = 128.0
[sub_resource type="Terrain3DAssets" id="Terrain3DAssets_h3i0q"]
mesh_list = Array[Terrain3DMeshAsset]([SubResource("Terrain3DMeshAsset_o05ja")])
[node name="SwampBackground" type="Terrain3D" unique_id=2116734893]
material = SubResource("Terrain3DMaterial_1of3m")
assets = SubResource("Terrain3DAssets_h3i0q")
show_checkered = true
top_level = true
metadata/_edit_lock_ = true
[gd_scene format=3 uid="uid://dypoks0inawgc"]
[sub_resource type="Gradient" id="Gradient_6edqv"]
offsets = PackedFloat32Array(0.2, 1)
colors = PackedColorArray(1, 1, 1, 1, 0, 0, 0, 1)
[sub_resource type="FastNoiseLite" id="FastNoiseLite_u12lg"]
noise_type = 2
frequency = 0.03
cellular_jitter = 3.0
cellular_return_type = 0
domain_warp_enabled = true
domain_warp_type = 1
domain_warp_amplitude = 50.0
domain_warp_fractal_type = 2
domain_warp_fractal_lacunarity = 1.5
domain_warp_fractal_gain = 1.0
[sub_resource type="NoiseTexture2D" id="NoiseTexture2D_yflbm"]
noise = SubResource("FastNoiseLite_u12lg")
color_ramp = SubResource("Gradient_6edqv")
seamless = true
[sub_resource type="Terrain3DMaterial" id="Terrain3DMaterial_vg6tp"]
_shader_parameters = {
&"bias_distance": null,
&"blend_sharpness": null,
&"depth_blur": null,
&"enable_macro_variation": null,
&"enable_projection": null,
&"flat_terrain_normals": null,
&"macro_variation1": null,
&"macro_variation2": null,
&"macro_variation_slope": null,
&"mipmap_bias": null,
&"noise1_angle": null,
&"noise1_offset": null,
&"noise1_scale": null,
&"noise2_scale": null,
&"noise_texture": SubResource("NoiseTexture2D_yflbm"),
&"projection_threshold": null
}
show_checkered = true
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_e17wc"]
transparency = 4
cull_mode = 2
vertex_color_use_as_albedo = true
backlight_enabled = true
backlight = Color(0.5, 0.5, 0.5, 1)
distance_fade_mode = 1
distance_fade_min_distance = 128.0
distance_fade_max_distance = 96.0
[sub_resource type="Terrain3DMeshAsset" id="Terrain3DMeshAsset_beaot"]
generated_type = 1
height_offset = 0.5
material_override = SubResource("StandardMaterial3D_e17wc")
last_lod = 0
last_shadow_lod = 0
lod0_range = 128.0
[sub_resource type="Terrain3DAssets" id="Terrain3DAssets_146h8"]
mesh_list = Array[Terrain3DMeshAsset]([SubResource("Terrain3DMeshAsset_beaot")])
[node name="DesertBackground" type="Terrain3D" unique_id=2095568987]
material = SubResource("Terrain3DMaterial_vg6tp")
assets = SubResource("Terrain3DAssets_146h8")
show_checkered = true
top_level = true
metadata/_edit_lock_ = true
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment