Import_3ds: Improved distance cue node setup
[blender-addons.git] / sun_position / __init__.py
blobe0bdf95bc99b5cd2d3eb0ef59f61b554b6d36dbc
1 # SPDX-FileCopyrightText: 2019-2023 Blender Foundation
3 # SPDX-License-Identifier: GPL-2.0-or-later
5 # --------------------------------------------------------------------------
6 # The sun positioning algorithms are based on the National Oceanic
7 # and Atmospheric Administration's (NOAA) Solar Position Calculator
8 # which rely on calculations of Jean Meeus' book "Astronomical Algorithms."
9 # Use of NOAA data and products are in the public domain and may be used
10 # freely by the public as outlined in their policies at
11 # www.nws.noaa.gov/disclaimer.php
12 # --------------------------------------------------------------------------
13 # The geo parser script is by Maximilian Högner, released
14 # under the GNU GPL license:
15 # http://hoegners.de/Maxi/geo/
16 # --------------------------------------------------------------------------
18 bl_info = {
19 "name": "Sun Position",
20 "author": "Michael Martin, Damien Picard",
21 "version": (3, 5, 5),
22 "blender": (3, 2, 0),
23 "location": "World > Sun Position",
24 "description": "Show sun position with objects and/or sky texture",
25 "doc_url": "{BLENDER_MANUAL_URL}/addons/lighting/sun_position.html",
26 "category": "Lighting",
29 if "bpy" in locals():
30 import importlib
31 importlib.reload(properties)
32 importlib.reload(ui_sun)
33 importlib.reload(hdr)
34 importlib.reload(sun_calc)
35 importlib.reload(translations)
37 else:
38 from . import properties, ui_sun, hdr, sun_calc, translations
40 import bpy
41 from bpy.app.handlers import persistent
44 register_classes, unregister_classes = bpy.utils.register_classes_factory(
45 (properties.SunPosProperties,
46 properties.SunPosAddonPreferences, ui_sun.SUNPOS_OT_AddPreset,
47 ui_sun.SUNPOS_PT_Presets, ui_sun.SUNPOS_PT_Panel,
48 ui_sun.SUNPOS_PT_Location, ui_sun.SUNPOS_PT_Time, hdr.SUNPOS_OT_ShowHdr))
51 @persistent
52 def sun_scene_handler(scene):
53 sun_props = bpy.context.scene.sun_pos_properties
55 # Force drawing update
56 sun_props.show_surface = sun_props.show_surface
57 sun_props.show_analemmas = sun_props.show_analemmas
58 sun_props.show_north = sun_props.show_north
60 # Force coordinates update
61 sun_props.latitude = sun_props.latitude
64 def register():
65 register_classes()
66 bpy.types.Scene.sun_pos_properties = (
67 bpy.props.PointerProperty(type=properties.SunPosProperties,
68 name="Sun Position",
69 description="Sun Position Settings"))
70 bpy.app.handlers.frame_change_post.append(sun_calc.sun_handler)
71 bpy.app.handlers.load_post.append(sun_scene_handler)
72 bpy.app.translations.register(__name__, translations.translations_dict)
75 def unregister():
76 bpy.app.translations.unregister(__name__)
77 bpy.app.handlers.frame_change_post.remove(sun_calc.sun_handler)
78 bpy.app.handlers.load_post.remove(sun_scene_handler)
79 del bpy.types.Scene.sun_pos_properties
80 unregister_classes()