@quenty/sunpositionutils 2.2.0 → 2.2.1-canary.283.715287b.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,14 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [2.2.1-canary.283.715287b.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/sunpositionutils@2.2.0...@quenty/sunpositionutils@2.2.1-canary.283.715287b.0) (2022-08-16)
7
+
8
+ **Note:** Version bump only for package @quenty/sunpositionutils
9
+
10
+
11
+
12
+
13
+
6
14
  # [2.2.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/sunpositionutils@2.1.1...@quenty/sunpositionutils@2.2.0) (2022-03-27)
7
15
 
8
16
  **Note:** Version bump only for package @quenty/sunpositionutils
package/LICENSE.md CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2014-2021 Quenty
3
+ Copyright (c) 2014-2022 Quenty
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@quenty/sunpositionutils",
3
- "version": "2.2.0",
4
- "description": "Utility to position the sun",
3
+ "version": "2.2.1-canary.283.715287b.0",
4
+ "description": "Utility to position the sun and to retrieve sun information specific to Roblox.",
5
5
  "keywords": [
6
6
  "Roblox",
7
7
  "Nevermore",
@@ -27,5 +27,5 @@
27
27
  "publishConfig": {
28
28
  "access": "public"
29
29
  },
30
- "gitHead": "501844bd6c3d3f765fd3032b997d8030bc963a1f"
30
+ "gitHead": "715287bf41b9be7160e69ec479cdc6c7d3ec5830"
31
31
  }
@@ -1,5 +1,10 @@
1
1
  --[=[
2
- Utility to position the sun
2
+ Utility to position the sun and to retrieve sun information specific to Roblox.
3
+
4
+ Note this is not an accurate guess of where the sun would be on earth, but rather
5
+ the computation to compute where Roblox is rendering the sun given the lighting
6
+ properties set.
7
+
3
8
  @class SunPositionUtils
4
9
  ]=]
5
10
  local SunPositionUtils = {}
@@ -8,31 +13,65 @@ local EARTH_TILT = 23.5
8
13
  local NORTH = Vector3.new(0, 0, -1)
9
14
  local ZAXIS = Vector3.new(0, 0, 1)
10
15
 
11
- function SunPositionUtils.getGeographicalLatitudeFromDirection(direction)
16
+ --[=[
17
+ Gets the geographical latitude from a vector pointing at the sun.
18
+
19
+ @param direction Vector3
20
+ @return number
21
+ ]=]
22
+ function SunPositionUtils.getGeographicalLatitudeFromDirection(direction: Vector3)
12
23
  local angle = math.atan2(direction.z, math.sqrt(direction.x^2 + direction.y^2))
13
24
  return angle/(math.pi*2)*360+EARTH_TILT
14
25
  end
15
26
 
16
27
  SunPositionUtils.getGeographicalLatitudeFromMoonDirection = SunPositionUtils.getGeographicalLatitudeFromDirection
17
28
 
18
- function SunPositionUtils.getClockTimeFromDirection(direction)
29
+ --[=[
30
+ Gets the clock time for the given direction.
31
+
32
+ @param direction Vector3
33
+ @return number
34
+ ]=]
35
+ function SunPositionUtils.getClockTimeFromDirection(direction: Vector3)
19
36
  local altitude = math.atan2(-direction.y, -direction.x)
20
37
 
21
38
  return (altitude/(math.pi*2)*24-6) % 24
22
39
  end
23
40
 
24
- function SunPositionUtils.getClockTimeFromMoonDirection(direction)
41
+ --[=[
42
+ Gets the clock time from the given moon direction.
43
+
44
+ @param direction Vector3
45
+ @return number
46
+ ]=]
47
+ function SunPositionUtils.getClockTimeFromMoonDirection(direction: Vector3)
25
48
  local altitude = math.atan2(direction.y, direction.x)
26
49
 
27
50
  return (altitude/(math.pi*2)*24-6) % 24
28
51
  end
29
52
 
30
- function SunPositionUtils.getDirection(azimuthRad, altitudeRad, north)
53
+ --[=[
54
+ Gets the direction the sun should be facing given the azimuth and altitude
55
+
56
+ @param azimuthRad number
57
+ @param altitudeRad number
58
+ @param north Vector3?
59
+ @return number
60
+ ]=]
61
+ function SunPositionUtils.getDirection(azimuthRad: number, altitudeRad: number, north: Vector3)
31
62
  local cframe = (CFrame.Angles(0, azimuthRad, 0) * CFrame.Angles(altitudeRad, 0, 0))
32
63
  return cframe:vectorToWorldSpace(north or NORTH)
33
64
  end
34
65
 
35
- function SunPositionUtils.getSunPosition(clockTime, geoLatitude)
66
+ --[=[
67
+ Estimates the sun position given the clockTime and geographical latitude.
68
+
69
+ @param clockTime number
70
+ @param geoLatitude number
71
+ @return Vector3 -- Sun position
72
+ @return Vector3 -- Moon position
73
+ ]=]
74
+ function SunPositionUtils.getSunPosition(clockTime: number, geoLatitude: number)
36
75
  local seconds = clockTime*60*60
37
76
  local DAY = 24 * 60 * 60
38
77
  local YEAR = 365.2564 * DAY