Compare commits

...

4 Commits

9 changed files with 37 additions and 27 deletions

View File

@@ -844,12 +844,12 @@ impl App {
);*/
moc.draw(camera, projection, shaders)?;
gl.blend_func_separate(
/*gl.blend_func_separate(
WebGl2RenderingContext::SRC_ALPHA,
WebGl2RenderingContext::ONE,
WebGl2RenderingContext::ONE,
WebGl2RenderingContext::ONE,
);
);*/
grid.draw(camera, projection, shaders)?;
// Ok(())
// },

View File

@@ -198,14 +198,15 @@ impl ProjetedGrid {
if self.enabled {
let fov = camera.get_field_of_view();
let bbox = fov.get_bounding_box();
let max_dim_px = camera.get_width().max(camera.get_height()) as f64;
let step_line_px = max_dim_px * 0.2;
//let max_dim_px = camera.get_width().max(camera.get_height()) as f64;
//let step_line_px = max_dim_px * 0.15;
let aspect = camera.get_aspect() as f64;
// update meridians
self.meridians = {
// Select the good step with a binary search
let step_lon_precised =
bbox.get_lon_size() * step_line_px / (camera.get_width() as f64);
let step_lon_precised = bbox.get_lon_size() * 0.15;
let step_lon = select_fixed_step(step_lon_precised);
let decimal_lon_prec = step_lon.to_degrees().log10().abs().ceil() as u8;
@@ -235,8 +236,7 @@ impl ProjetedGrid {
};
self.parallels = {
let step_lat_precised =
bbox.get_lat_size() * step_line_px / (camera.get_height() as f64);
let step_lat_precised = aspect * bbox.get_lat_size() * 0.15;
let step_lat = select_fixed_step(step_lat_precised);
let decimal_lat_prec = step_lat.to_degrees().log10().abs().ceil() as u8;
@@ -349,7 +349,7 @@ const GRID_STEPS: &[f64] = &[
0.08726647,
0.17453293,
0.34906585,
std::f64::consts::FRAC_PI_4,
std::f64::consts::FRAC_PI_6,
];
fn select_fixed_step(fov: f64) -> f64 {

View File

@@ -1,17 +1,25 @@
#version 300 es
precision lowp float;
precision highp float;
out vec4 color;
in float l;
in vec2 l;
uniform vec4 u_color;
uniform float u_thickness;
uniform float u_width;
uniform float u_height;
void main() {
// Multiply vertex color with texture color (in linear space).
// Linear color is written and blended in Framebuffer and converted to sRGB later
if (l > 0.05) {
if (l.x > 0.05) {
discard;
} else {
color = u_color;
// distance from line to compute the anti-aliasing
float dist = abs((u_thickness + 2.0) * l.y);
float half_thickness = (u_thickness + 2.0) * 0.5;
color.a = color.a * (1.0 - smoothstep(half_thickness - 1.0, half_thickness, dist));
}
}

View File

@@ -11,7 +11,7 @@ uniform float u_width;
uniform float u_height;
uniform float u_thickness;
out float l;
out vec2 l;
#include ../projection/projection.glsl;
@@ -27,7 +27,6 @@ void main() {
vec2 p_b_clip = proj(p_b_w);
vec2 da = p_a_clip - p_b_clip;
l = dot(da, da);
vec2 p_a_ndc = p_a_clip / (ndc_to_clip * czf);
vec2 p_b_ndc = p_b_clip / (ndc_to_clip * czf);
@@ -37,6 +36,12 @@ void main() {
vec2 y_b = normalize(vec2(-x_b.y, x_b.x));
float ndc2pix = 2.0 / u_width;
vec2 p_ndc = p_a_ndc + x_b * vertex.x + u_thickness * y_b * vertex.y * vec2(1.0, u_width/u_height) * ndc2pix;
vec2 p_ndc_x = x_b * vertex.x;
vec2 p_ndc_y = (u_thickness + 2.0) * y_b * vertex.y * vec2(1.0, u_width/u_height) * ndc2pix;
vec2 p_ndc = p_a_ndc + p_ndc_x + p_ndc_y;
gl_Position = vec4(p_ndc, 0.f, 1.f);
l = vec2(dot(da, da), vertex.y);
}

View File

@@ -4,7 +4,7 @@ layout (location = 0) in vec2 p_a;
layout (location = 1) in vec2 p_b;
layout (location = 2) in vec2 vertex;
out float l;
out vec2 l;
uniform float u_width;
uniform float u_height;
@@ -16,6 +16,7 @@ void main() {
float ndc2pix = 2.0 / u_width;
vec2 p = p_a + x_b * vertex.x + u_thickness * y_b * vertex.y * vec2(1.0, u_width/u_height) * ndc2pix;
vec2 p = p_a + x_b * vertex.x + (u_thickness + 2.0) * y_b * vertex.y * vec2(1.0, u_width/u_height) * ndc2pix;
gl_Position = vec4(p, 0.f, 1.f);
l = vec2(0.0, vertex.y);
}

View File

@@ -736,7 +736,7 @@ export let Aladin = (function () {
gridOptions: {
enabled: false,
showLabels: true,
thickness: 2,
thickness: 1,
labelSize: 15,
},
projection: "SIN",

View File

@@ -26,7 +26,7 @@ import { ALEvent } from "./events/ALEvent.js";
* @property {Boolean} [perimeter=false] - Draw the perimeter of the MOC only with `options.color`.
* @property {string} [edge=!fill && !perimeter] - Draw the edges of the HEALPix cells with `options.color`.
The HEALPix cell edges compositing the MOC will be drawn if `fill` and `perimeter` are false
* @property {number} [lineWidth=3] - The line width in pixels
* @property {number} [lineWidth=1] - The line width in pixels
* @property {number} [opacity=1.0] - The opacity of the colors
*/
@@ -93,7 +93,7 @@ export let MOC = (function() {
}
this.opacity = Math.max(0, Math.min(1, this.opacity)); // 0 <= this.opacity <= 1
this.lineWidth = options["lineWidth"] || 3;
this.lineWidth = options["lineWidth"] || 1;
//this.proxyCalled = false; // this is a flag to check whether we already tried to load the MOC through the proxy

View File

@@ -304,7 +304,6 @@ export class OverlayStackBox extends Box {
let moc = A.MOCFromURL(url, {
name: file.name,
lineWidth: 3.0,
});
self.aladin.addMOC(moc);
},
@@ -347,7 +346,6 @@ export class OverlayStackBox extends Box {
{ ra, dec, radius },
{
name: "cone",
lineWidth: 3.0,
}
);
self.aladin.addMOC(moc);
@@ -418,7 +416,6 @@ export class OverlayStackBox extends Box {
},
{
name: "rect",
lineWidth: 3.0,
}
);
self.aladin.addMOC(moc);
@@ -463,7 +460,6 @@ export class OverlayStackBox extends Box {
{ ra, dec },
{
name: "poly",
lineWidth: 3.0,
}
);
self.aladin.addMOC(moc);

View File

@@ -72,7 +72,7 @@ export class SAMPConnector {
var params = message["samp.params"];
const {url, name} = params;
let moc = A.MOCFromURL(url, {name, lineWidth: 3});
let moc = A.MOCFromURL(url, {name});
aladin.addMOC(moc);
};