Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add starfield layer #86

Merged
merged 15 commits into from
May 15, 2017
Merged

Add starfield layer #86

merged 15 commits into from
May 15, 2017

Conversation

strikerM
Copy link
Contributor

No description provided.

@pdavidc pdavidc added this to the v0.9.0 milestone Feb 22, 2017
@AkeluX
Copy link
Contributor

AkeluX commented Mar 28, 2017

This isn't directly for the starfield, but now that we include an util for computing the position of the sun, we could let the atmosphere layer react to its time property as well. What do you think?

@pdavidc
Copy link
Contributor

pdavidc commented Mar 28, 2017

Yann, I think that's a good idea, and the CelestialProjection class is a good start. I'm unsure of this class' name and place within the SDK. By name and some methods CelestialProjection seems related to GeographicProjection, but CelestialProjection is not a map projection and includes some utilities that appear more general. Would you be willing to review this class on the basis of its naming and its cohesion?

@AkeluX
Copy link
Contributor

AkeluX commented Mar 28, 2017

Absolutely. I'll create an issue to track this idea of changing the Atmosphere layer a bit. We can first finalise the Starfield and this new util. Some reviews from my side are also pending here by the way.

@AkeluX
Copy link
Contributor

AkeluX commented Mar 31, 2017

The goal of CelestialProjection currently boils down to computing the sun's position in geographic and celestial coordinates. celestialToGeographic, computeJulianDate and normalizeAngle are actually helpers to reach this purpose. I would thus remove them from the public interface and have computeSunCelestialLocation take a regular date as argument. This should help with the cohesion from the perspective of the public interface.

I haven’t found such normalization of angles and conversions (celestialToGeographic and Julian date) elsewhere in the SDK so they could stay in this class in my opinion.

Regarding the class name, I would have it relate to its core purpose. Maybe something like SunPosition with methods like getAsGeographicLocation and getAsCelestialLocation.

Regarding the location of this class in the SDK, I don’t see a more appropriate place than the very generic util, at the moment.

@strikerM @pdavidc what do you think?

@strikerM
Copy link
Contributor Author

strikerM commented Apr 3, 2017

CelestialProjection was intended to be used for any celestial body.

At the moment CelestialProjection is only useful for the Sun position, but it was originally implemented with the Moon as well and had the methods computeMoonCelestialLocation and computeMoonGeographicLocation.

The methods celestialToGeographic, computeJulianDate and normalizeAngle are helpers that can be used for any celestial body.

My reasoning was that if we want to add a new celestial body, it would only require a computeXCelestialLocation method for that particular object.

All celestial bodies (stars, Sun, Moon) require converting to julianDate.
The reason computeSunCelestialLocation takes a julianDate instead of a javascript Date was so that this conversion is done only once and then reused.

There is a computeSunGeographicLocation method that takes a javascript Date are returns LatLon.

Let me know if you want me to change anything.

@strikerM
Copy link
Contributor Author

strikerM commented Apr 5, 2017

I refactored CelestialProjection, let me know what you think.
@AkeluX @pdavidc

@AkeluX
Copy link
Contributor

AkeluX commented Apr 7, 2017

For me, it's fine.

' float angleDivisions = angle / 360.0;\n' +
' return 360.0 * (angleDivisions - floor(angleDivisions));\n' +
'}\n' +

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@strikerM, could this be replaced by the built-in GLSL step function?
http://docs.gl/el3/step


return JD0h + dayFraction;
},

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@strikerM, This function looks appropriate for WWMath. Would you please move it there? Also, if you'd compare it to Android's WWMath.normalizeAngle we need to ensure that the two are equivalent.

removed normalizeAngle from SunPosition
replaced if_gt function with the build in glsl step function
@strikerM
Copy link
Contributor Author

@pdavidc
I've added normalizeAngle360, from WWAndroid, to WWMath and replaced the if_gt function with the built in step function.

@AkeluX
Copy link
Contributor

AkeluX commented Apr 28, 2017

@strikerM with your latest commit, it seems you've removed the test associated with the normalizeAngle360 logic. Could you create a WWMath.test.js and add your test there instead?

@AkeluX AkeluX changed the title Starfield layer Add starfield layer Apr 28, 2017
@strikerM
Copy link
Contributor Author

strikerM commented May 2, 2017

I've added the test.

@pdavidc pdavidc merged commit 3566f8c into develop May 15, 2017
@AkeluX AkeluX deleted the feature/starfield branch May 16, 2017 11:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

None yet

3 participants