feat: sync visual day-night cycle with simulation clock
DayNightCycle now reads time_of_day from SimulationManager group node, falling back to self-tracked elapsed for lookdev scenes. Simulation starts at 06:00 morning (tick 50) by default. TimeDial reads directly from SimulationManager and displays HH:MM format with a 24-hour dial arc. Removed initial_cycle override from JajceLookdev.
This commit is contained in:
@@ -7,9 +7,6 @@
|
||||
|
||||
[node name="JajceWorld" parent="." instance=ExtResource("1_world")]
|
||||
|
||||
[node name="DayNightCycle" parent="JajceWorld" index="9"]
|
||||
initial_cycle = 0.38
|
||||
|
||||
[node name="BeautyCamera" type="Camera3D" parent="."]
|
||||
position = Vector3(44, 34, 44)
|
||||
current = true
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
extends Node
|
||||
|
||||
@export var cycle_duration_seconds := 240.0
|
||||
@export_range(0.0, 1.0, 0.01) var initial_cycle := 0.35
|
||||
@export_range(0.0, 1.0, 0.01) var initial_cycle := 0.25
|
||||
@export var directional_light: DirectionalLight3D
|
||||
@export var world_environment: WorldEnvironment
|
||||
|
||||
@@ -36,19 +36,26 @@ const SUNRISE_LIGHT_COLOR := Color(1, 0.6, 0.45, 1)
|
||||
const SUNRISE_SUNSET_ENERGY := 0.8
|
||||
|
||||
var elapsed := 0.0
|
||||
var _simulation_node: Node
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
elapsed = cycle_duration_seconds * initial_cycle
|
||||
_apply_light_rotation(initial_cycle)
|
||||
_apply_environment(initial_cycle)
|
||||
_simulation_node = get_tree().get_first_node_in_group("simulation_manager")
|
||||
if _simulation_node == null:
|
||||
elapsed = cycle_duration_seconds * initial_cycle
|
||||
_apply_light_rotation(initial_cycle)
|
||||
_apply_environment(initial_cycle)
|
||||
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
elapsed += delta
|
||||
if elapsed >= cycle_duration_seconds:
|
||||
elapsed = fmod(elapsed, cycle_duration_seconds)
|
||||
var cycle := elapsed / cycle_duration_seconds
|
||||
func _process(_delta: float) -> void:
|
||||
var cycle: float
|
||||
if _simulation_node != null and "clock" in _simulation_node:
|
||||
cycle = _simulation_node.clock.time_of_day()
|
||||
else:
|
||||
elapsed += _delta
|
||||
if elapsed >= cycle_duration_seconds:
|
||||
elapsed = fmod(elapsed, cycle_duration_seconds)
|
||||
cycle = elapsed / cycle_duration_seconds
|
||||
_apply_light_rotation(cycle)
|
||||
_apply_environment(cycle)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user