maplibre-gl-nightlayer 1.0.0-alpha.0 → 1.0.0-alpha.1

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.
Files changed (2) hide show
  1. package/dist/main.js +2 -2
  2. package/package.json +1 -1
package/dist/main.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";import{MercatorCoordinate as l}from"maplibre-gl";function m(h){return h*Math.PI/180}function g(h){return h/Math.PI*180}export class NightLayer{id="nightlayer";type="custom";renderingMode="2d";#e;#h;#i;#r;#o;#a;#t;#n;#s;constructor(t={}){this.#e=t.date??null,this.#h=t.opacity??.5,this.#i=t.color??[0,0,0],this.#r=t.twilightSteps??0,this.#o=t.twilightStepAngle??6,this.#a=t.twilightAttenuation??.5}getSubsolarPoint(t){const e=(t.getTime()-Date.UTC(t.getUTCFullYear(),0,0))/864e5,a=2*Math.PI/365.24,n=m(23.44),r=.0167,i=(e+9)*a,o=i+2*r*Math.sin((e-3)*a),s=(i-Math.atan2(Math.sin(o),Math.cos(o)*Math.cos(n)))/Math.PI,u=720*(s-Math.trunc(s+.5)),c=-15*(t.getUTCHours()+t.getUTCMinutes()/60+t.getUTCSeconds()/3600-12+u/60),f=g(Math.asin(Math.sin(-n)*Math.cos(o)));return{subsolarLng:c,subsolarLat:f}}getDate(){return this.#e}setDate(t){this.#e=t}getColor(){return this.#i}setColor(t){this.#i=t}getTwilightSteps(){return this.#r}setTwilightSteps(t){this.#r=t}getTwilightStepAngle(){return this.#o}setTwilightStepAngle(t){this.#o=t}getTwilightAttenuation(){return this.#a}setTwilightAttenuation(t){this.#a=t}onAdd(t,e){const a=`
1
+ "use strict";import{MercatorCoordinate as l}from"maplibre-gl";function f(h){return h*Math.PI/180}function p(h){return h/Math.PI*180}export class NightLayer{id="nightlayer";type="custom";renderingMode="2d";#e;#h;#i;#r;#o;#a;#t;#n;#s;constructor(t={}){this.#e=t.date??null,this.#h=t.opacity??.5,this.#i=t.color??[0,0,0],this.#r=t.twilightSteps??0,this.#o=t.twilightStepAngle??6,this.#a=t.twilightAttenuation??.5}getSubsolarPoint(t){const e=(t.getTime()-Date.UTC(t.getUTCFullYear(),0,0))/864e5,a=2*Math.PI/365.24,n=f(23.44),r=.0167,i=(e+9)*a,o=i+2*r*Math.sin((e-3)*a),s=(i-Math.atan2(Math.sin(o),Math.cos(o)*Math.cos(n)))/Math.PI,u=720*(s-Math.trunc(s+.5)),c=-15*(t.getUTCHours()+t.getUTCMinutes()/60+t.getUTCSeconds()/3600-12+u/60),m=p(Math.asin(Math.sin(-n)*Math.cos(o)));return{subsolarLng:c,subsolarLat:m}}getDate(){return this.#e}setDate(t){this.#e=t}getColor(){return this.#i}setColor(t){this.#i=t}getTwilightSteps(){return this.#r}setTwilightSteps(t){this.#r=t}getTwilightStepAngle(){return this.#o}setTwilightStepAngle(t){this.#o=t}getTwilightAttenuation(){return this.#a}setTwilightAttenuation(t){this.#a=t}onAdd(t,e){const a=`
2
2
  precision highp float;
3
3
 
4
4
  attribute vec2 a_position;
@@ -51,7 +51,7 @@
51
51
  if (twilightSteps > 0.) {
52
52
  twilightLevel = ceil(clamp(twilightLevel, 0., twilightSteps));
53
53
  }
54
- float brightness = clamp(pow(att, twilightLevel), 0., 1.);
54
+ float brightness = clamp(pow(clamp(1. - att, 0., 1.), twilightLevel), 0., 1.);
55
55
  float darkness = (1. - brightness);
56
56
 
57
57
  gl_FragColor = vec4(u_color / 255., 1.0) * darkness * u_opacity;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "maplibre-gl-nightlayer",
3
- "version": "1.0.0-alpha.0",
3
+ "version": "1.0.0-alpha.1",
4
4
  "description": "A Night Layer for MapLibre GL JS",
5
5
  "type": "module",
6
6
  "main": "dist/main.js",