1 # SPDX-License-Identifier: GPL-2.0-or-later
3 # --------------------------------------------------------------------------
4 # The sun positioning algorithms are based on the National Oceanic
5 # and Atmospheric Administration's (NOAA) Solar Position Calculator
6 # which rely on calculations of Jean Meeus' book "Astronomical Algorithms."
7 # Use of NOAA data and products are in the public domain and may be used
8 # freely by the public as outlined in their policies at
9 # www.nws.noaa.gov/disclaimer.php
10 # --------------------------------------------------------------------------
11 # The geo parser script is by Maximilian Högner, released
12 # under the GNU GPL license:
13 # http://hoegners.de/Maxi/geo/
14 # --------------------------------------------------------------------------
17 "name": "Sun Position",
18 "author": "Michael Martin, Damien Picard",
21 "location": "World > Sun Position",
22 "description": "Show sun position with objects and/or sky texture",
23 "doc_url": "{BLENDER_MANUAL_URL}/addons/lighting/sun_position.html",
24 "category": "Lighting",
29 importlib
.reload(properties
)
30 importlib
.reload(ui_sun
)
32 importlib
.reload(translations
)
35 from . import properties
, ui_sun
, hdr
, translations
38 from bpy
.app
.handlers
import persistent
41 register_classes
, unregister_classes
= bpy
.utils
.register_classes_factory(
42 (properties
.SunPosProperties
,
43 properties
.SunPosAddonPreferences
, ui_sun
.SUNPOS_OT_AddPreset
,
44 ui_sun
.SUNPOS_PT_Presets
, ui_sun
.SUNPOS_PT_Panel
,
45 ui_sun
.SUNPOS_PT_Location
, ui_sun
.SUNPOS_PT_Time
, hdr
.SUNPOS_OT_ShowHdr
))
49 def sun_scene_handler(scene
):
50 sun_props
= bpy
.context
.scene
.sun_pos_properties
52 # Force drawing update
53 sun_props
.show_surface
= sun_props
.show_surface
54 sun_props
.show_analemmas
= sun_props
.show_analemmas
55 sun_props
.show_north
= sun_props
.show_north
57 # Force coordinates update
58 sun_props
.latitude
= sun_props
.latitude
63 bpy
.types
.Scene
.sun_pos_properties
= (
64 bpy
.props
.PointerProperty(type=properties
.SunPosProperties
,
66 description
="Sun Position Settings"))
67 bpy
.app
.handlers
.frame_change_post
.append(sun_calc
.sun_handler
)
68 bpy
.app
.handlers
.load_post
.append(sun_scene_handler
)
69 bpy
.app
.translations
.register(__name__
, translations
.translations_dict
)
73 bpy
.app
.translations
.unregister(__name__
)
74 bpy
.app
.handlers
.frame_change_post
.remove(sun_calc
.sun_handler
)
75 bpy
.app
.handlers
.load_post
.remove(sun_scene_handler
)
76 del bpy
.types
.Scene
.sun_pos_properties