From bcfe829b03f3ca18c85d3a90fb0d80f8fad16780 Mon Sep 17 00:00:00 2001 From: bmatthieu3 Date: Thu, 25 May 2023 14:36:23 +0200 Subject: [PATCH] use vite producing es and umd aladin lite module types. The umd is consistent with what is being used since a long time (including manually the aladin lite script) --- examples/al-ESO-outreach.html | 5 +- examples/al-HST-outreach.html | 5 +- examples/al-aas225.html | 6 +- examples/al-adass2022.html | 6 +- examples/al-additive-blend.html | 6 +- examples/al-animation-CS-CDS-2022.html | 6 +- examples/al-animation.html | 6 +- examples/al-artifact.html | 6 +- examples/al-badbaselayer.html | 6 +- examples/al-cat-custom-draw-function.html | 6 +- examples/al-cat-custom-shape.html | 6 +- examples/al-catalog-hips-filter.html | 6 +- examples/al-catalog-hips-shape.html | 6 +- examples/al-catalog-hips.html | 6 +- examples/al-cfht.html | 6 +- examples/al-chinavo.html | 6 +- examples/al-coronelli.html | 6 +- examples/al-displayFITS.html | 5 +- examples/al-displayJPG.html | 7 +- examples/al-distortion.html | 5 +- examples/al-easy-access-simbad-ned.html | 6 +- examples/al-easy-access-vizier.html | 5 +- examples/al-ellipse.html | 6 +- examples/al-event-listeners.html | 6 +- examples/al-footprints.html | 6 +- examples/al-gaiadr3.html | 4 +- examples/al-gotoobject.html | 6 +- examples/al-gw.html | 6 +- examples/al-hips-from-url.html | 6 +- examples/al-hips-local.html | 7 +- examples/al-hips-order-list.html | 6 +- examples/al-image-layer-by-name.html | 6 +- examples/al-init-custom-options.html | 6 +- examples/al-jwst.html | 6 +- examples/al-load-votables-by-url.html | 6 +- examples/al-marker-creation.html | 6 +- examples/al-mars-features.html | 5 +- examples/al-mars.html | 6 +- examples/al-moc-isophot.html | 6 +- examples/al-moc-json.html | 6 +- examples/al-moc-sdss9.html | 6 +- examples/al-moc-sky-fraction.html | 6 +- examples/al-moment.html | 6 +- examples/al-multi-catalog-table.html | 5 +- examples/al-multiple-instances.html | 6 +- examples/al-multiple-surveys.html | 6 +- examples/al-no-cors.html | 6 +- examples/al-not-found.html | 6 +- examples/al-obscore.html | 7 +- examples/al-onames-labels.html | 6 +- examples/al-overlay-image-layer.html | 6 +- examples/al-perseverence.html | 5 +- examples/al-polyline.html | 6 +- examples/al-remove-source.html | 4 +- examples/al-response-div.html | 6 +- examples/al-reverse-longitude.html | 6 +- examples/al-rightclick-fits.html | 6 +- examples/al-sdc2.html | 6 +- examples/al-set-colormap.html | 5 +- examples/al-simbad-density.html | 5 +- examples/al-simbad-pointer.html | 6 +- examples/al-snippet.html | 2 +- examples/al-stcs-footprints.html | 7 +- examples/al-stephan-quintet.html | 6 +- examples/al-zoom-meerkat.html | 5 +- examples/al-zoomchanged.html | 4 +- examples/index.html | 27 +- examples/index_es.html | 47 +++ examples/index_umd.html | 47 +++ examples/open_all.sh | 5 - package.json | 41 +-- src/core/Cargo.toml | 2 +- src/core/al-api/src/color.rs | 2 +- src/core/src/app.rs | 1 - src/glsl/webgl2/catalogs/aitoff.vert | 2 +- src/glsl/webgl2/catalogs/arc.vert | 2 +- src/glsl/webgl2/catalogs/healpix.vert | 2 +- src/glsl/webgl2/catalogs/mercator.vert | 2 +- src/glsl/webgl2/catalogs/mollweide.vert | 2 +- src/glsl/webgl2/catalogs/ortho.vert | 2 +- src/glsl/webgl2/catalogs/tan.vert | 2 +- src/glsl/webgl2/colormaps/colormap.frag | 2 +- src/glsl/webgl2/fits/frag_isampler.glsl | 2 +- src/glsl/webgl2/fits/frag_sampler.glsl | 2 +- src/glsl/webgl2/fits/frag_usampler.glsl | 2 +- src/glsl/webgl2/hips/color.glsl | 8 +- src/glsl/webgl2/hips/color_i.glsl | 6 +- src/glsl/webgl2/hips/color_u.glsl | 6 +- src/glsl/webgl2/hips/rasterizer/color.frag | 2 +- .../rasterizer/grayscale_to_colormap.frag | 2 +- .../rasterizer/grayscale_to_colormap_i.frag | 2 +- .../rasterizer/grayscale_to_colormap_u.frag | 2 +- src/glsl/webgl2/hips/rasterizer/raster.vert | 2 +- src/glsl/webgl2/hips/raytracer/color.frag | 4 +- .../hips/raytracer/grayscale_to_colormap.frag | 4 +- .../raytracer/grayscale_to_colormap_i.frag | 4 +- .../raytracer/grayscale_to_colormap_u.frag | 4 +- src/glsl/webgl2/hips/raytracer/raytracer.vert | 2 +- src/js/A.js | 311 ++++++++++++++++++ src/js/Aladin.js | 256 +------------- src/js/Catalog.js | 1 + src/js/ImageFITS.js | 1 - src/js/ImageSurvey.js | 1 + src/js/URLBuilder.js | 6 +- src/js/View.js | 95 +----- vite.config.js | 48 +++ 106 files changed, 657 insertions(+), 683 deletions(-) create mode 100644 examples/index_es.html create mode 100644 examples/index_umd.html delete mode 100755 examples/open_all.sh create mode 100644 src/js/A.js create mode 100644 vite.config.js diff --git a/examples/al-ESO-outreach.html b/examples/al-ESO-outreach.html index de523ab8..d8af8109 100644 --- a/examples/al-ESO-outreach.html +++ b/examples/al-ESO-outreach.html @@ -10,13 +10,12 @@ This Web resource contains HiPS(*) components for ESO EPO progressive sur
-
  Overlay opacity:
-
  Overlay opacity:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - -
 
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + -
- - - - - - - - - - - - - - - + - - - - + - diff --git a/examples/index_es.html b/examples/index_es.html new file mode 100644 index 00000000..68e1a23a --- /dev/null +++ b/examples/index_es.html @@ -0,0 +1,47 @@ + + + + + + +
+ + + + + diff --git a/examples/index_umd.html b/examples/index_umd.html new file mode 100644 index 00000000..14e0f606 --- /dev/null +++ b/examples/index_umd.html @@ -0,0 +1,47 @@ + + + + + + +
+ + + + + + diff --git a/examples/open_all.sh b/examples/open_all.sh deleted file mode 100755 index bd4fe1e2..00000000 --- a/examples/open_all.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - -for filename in *.html; do - google-chrome http://localhost:8080/${filename} -done diff --git a/package.json b/package.json index 2e12fe8b..0ab391ca 100644 --- a/package.json +++ b/package.json @@ -1,14 +1,21 @@ { "homepage": "https://aladin.u-strasbg.fr/", "name": "aladin-lite", + "type": "module", "version": "3.1.0", "description": "An astronomical HiPS visualizer in the browser", "author": "Thomas Boch and Matthieu Baumann", "license": "GPL-3", - "main": "dist/aladin.js", + "module": "./dist/aladin.js", + "main": "./dist/aladin.js", "files": [ - "dist/*" + "dist" ], + "exports": { + ".": { + "import": "./dist/aladin.js" + } + }, "repository": { "type": "git", "url": "https://github.com/cds-astro/aladin-lite" @@ -21,32 +28,26 @@ "HiPS" ], "scripts": { + "wasm": "wasm-pack build ./src/core --target web --release --out-name core -- --features webgl2", "package-tar": "tar -zcvf AladinLiteAssets.tar.gz dist/*", "predeploy": "npm run build && npm run package-tar", "deploy": "./deploy-dbg.sh", - "build": "webpack && sed \"s/\\\\.\\\\/\\\\.\\\\.\\\\/aladin\\\\.js/https:\\\\/\\\\/aladin.cds.unistra.fr\\\\/AladinLite\\\\/api\\\\/v3\\\\/latest\\\\/aladin.js/g\" examples/index.html > dist/index.html", - "serve": "webpack-dev-server" + "build": "npm run wasm && vite build && sed \"s/\\\\.\\\\/\\\\.\\\\.\\\\/aladin\\\\.js/https:\\\\/\\\\/aladin.cds.unistra.fr\\\\/AladinLite\\\\/api\\\\/v3\\\\/latest\\\\/aladin.js/g\" examples/index.html > dist/index.html", + "dev": "npm run build && vite", + "preview": "vite preview" }, "devDependencies": { - "@babel/core": "^7.18.5", - "@babel/preset-env": "^7.18.2", - "@wasm-tool/wasm-pack-plugin": "^1.6.0", - "babel-loader": "^8.2.5", "npm": "^8.19.2", - "terser-webpack-plugin": "^5.3.3", - "webpack": "^5.74.0", - "webpack-cli": "^4.9.0", - "webpack-dev-server": "^4.7.4", - "webpack-glsl-loader": "^1.0.1", - "webpack-glsl-minify": "^1.5.0" + "terser": "^5.17.6", + "vite": "^4.3.8", + "vite-plugin-css-injected-by-js": "^3.1.1", + "vite-plugin-glsl": "^1.1.2", + "vite-plugin-top-level-await": "^1.3.1", + "vite-plugin-wasm": "^3.2.2", + "vite-plugin-wasm-pack": "^0.1.12" }, "dependencies": { "autocompleter": "^6.1.3", - "babel-preset-es2015": "^6.24.1", - "css-loader": "^5.0.1", - "file-loader": "^6.1.0", - "jquery": "^3.6.1", - "style-loader": "^3.3.1", - "wasm-pack": "^0.10.3" + "jquery": "^3.6.1" } } diff --git a/src/core/Cargo.toml b/src/core/Cargo.toml index 9bc08c39..d4d86dff 100644 --- a/src/core/Cargo.toml +++ b/src/core/Cargo.toml @@ -119,7 +119,7 @@ codegen-units = 256 rpath = false [profile.release] -opt-level = 3 +opt-level = 'z' debug = false debug-assertions = false overflow-checks = false diff --git a/src/core/al-api/src/color.rs b/src/core/al-api/src/color.rs index c73f5191..c3db39d2 100644 --- a/src/core/al-api/src/color.rs +++ b/src/core/al-api/src/color.rs @@ -1,6 +1,6 @@ use wasm_bindgen::prelude::*; -#[wasm_bindgen(raw_module = "../src/js/Color")] +#[wasm_bindgen(raw_module = "../../js/Color")] extern "C" { pub type Color; diff --git a/src/core/src/app.rs b/src/core/src/app.rs index cdab68be..bc3e814e 100644 --- a/src/core/src/app.rs +++ b/src/core/src/app.rs @@ -135,7 +135,6 @@ impl App { WebGl2RenderingContext::ONE, WebGl2RenderingContext::ONE, ); - // TODO: https://caniuse.com/?search=scissor is not supported for safari <= 14.1 // When it will be supported nearly everywhere, we will need to uncomment this line to // enable it diff --git a/src/glsl/webgl2/catalogs/aitoff.vert b/src/glsl/webgl2/catalogs/aitoff.vert index 6c049c6f..fd32e6f5 100644 --- a/src/glsl/webgl2/catalogs/aitoff.vert +++ b/src/glsl/webgl2/catalogs/aitoff.vert @@ -15,7 +15,7 @@ uniform vec2 kernel_size; out vec2 out_uv; out vec3 out_p; -@include "../hips/projection.glsl" +#include ../hips/projection.glsl; void main() { vec3 p = vec3(inv_model * vec4(center, 1.0f)); diff --git a/src/glsl/webgl2/catalogs/arc.vert b/src/glsl/webgl2/catalogs/arc.vert index 2695ad3e..762feb94 100644 --- a/src/glsl/webgl2/catalogs/arc.vert +++ b/src/glsl/webgl2/catalogs/arc.vert @@ -14,7 +14,7 @@ uniform vec2 kernel_size; out vec2 out_uv; out vec3 out_p; -@include "../hips/projection.glsl" +#include ../hips/projection.glsl; void main() { vec3 p = vec3(inv_model * vec4(center, 1.0f)); diff --git a/src/glsl/webgl2/catalogs/healpix.vert b/src/glsl/webgl2/catalogs/healpix.vert index 8e0d78bd..efd132b4 100644 --- a/src/glsl/webgl2/catalogs/healpix.vert +++ b/src/glsl/webgl2/catalogs/healpix.vert @@ -15,7 +15,7 @@ uniform vec2 kernel_size; out vec2 out_uv; out vec3 out_p; -@include "../hips/projection.glsl" +#include ../hips/projection.glsl; void main() { vec3 p = vec3(inv_model * vec4(center, 1.0f)); diff --git a/src/glsl/webgl2/catalogs/mercator.vert b/src/glsl/webgl2/catalogs/mercator.vert index a2332039..781f8e27 100644 --- a/src/glsl/webgl2/catalogs/mercator.vert +++ b/src/glsl/webgl2/catalogs/mercator.vert @@ -14,7 +14,7 @@ uniform vec2 kernel_size; out vec2 out_uv; out vec3 out_p; -@include "../hips/projection.glsl" +#include ../hips/projection.glsl; void main() { vec3 p = vec3(inv_model * vec4(center, 1.0f)); diff --git a/src/glsl/webgl2/catalogs/mollweide.vert b/src/glsl/webgl2/catalogs/mollweide.vert index 4c593583..de291359 100644 --- a/src/glsl/webgl2/catalogs/mollweide.vert +++ b/src/glsl/webgl2/catalogs/mollweide.vert @@ -14,7 +14,7 @@ uniform vec2 kernel_size; out vec2 out_uv; out vec3 out_p; -@include "../hips/projection.glsl" +#include ../hips/projection.glsl; void main() { vec3 p = vec3(inv_model * vec4(center, 1.0f)); diff --git a/src/glsl/webgl2/catalogs/ortho.vert b/src/glsl/webgl2/catalogs/ortho.vert index f08c8f60..f7b5b5f5 100644 --- a/src/glsl/webgl2/catalogs/ortho.vert +++ b/src/glsl/webgl2/catalogs/ortho.vert @@ -14,7 +14,7 @@ uniform vec2 kernel_size; out vec2 out_uv; out vec3 out_p; -@include "../hips/projection.glsl" +#include ../hips/projection.glsl; void main() { vec3 p = vec3(inv_model * vec4(center, 1.0f)); diff --git a/src/glsl/webgl2/catalogs/tan.vert b/src/glsl/webgl2/catalogs/tan.vert index 551a9eda..c29cd976 100644 --- a/src/glsl/webgl2/catalogs/tan.vert +++ b/src/glsl/webgl2/catalogs/tan.vert @@ -15,7 +15,7 @@ uniform vec2 kernel_size; out vec2 out_uv; out vec3 out_p; -@include "../hips/projection.glsl" +#include ../hips/projection.glsl; void main() { vec3 p = vec3(inv_model * vec4(center, 1.0f)); diff --git a/src/glsl/webgl2/colormaps/colormap.frag b/src/glsl/webgl2/colormaps/colormap.frag index d737a3be..fb4671da 100644 --- a/src/glsl/webgl2/colormaps/colormap.frag +++ b/src/glsl/webgl2/colormaps/colormap.frag @@ -8,7 +8,7 @@ out vec4 color; uniform sampler2D texture_fbo; uniform float alpha; -@include "./colormap.glsl" +#include ./colormap.glsl; void main() { float opacity = texture(texture_fbo, out_uv).r; diff --git a/src/glsl/webgl2/fits/frag_isampler.glsl b/src/glsl/webgl2/fits/frag_isampler.glsl index f7922414..b5d61f8f 100644 --- a/src/glsl/webgl2/fits/frag_isampler.glsl +++ b/src/glsl/webgl2/fits/frag_isampler.glsl @@ -11,7 +11,7 @@ in vec2 frag_uv; uniform isampler2D tex; uniform float opacity; -@include "../hips/color.glsl" +#include ../hips/color.glsl; void main() { ivec4 color = texture(tex, frag_uv); diff --git a/src/glsl/webgl2/fits/frag_sampler.glsl b/src/glsl/webgl2/fits/frag_sampler.glsl index 62384cee..27acef92 100644 --- a/src/glsl/webgl2/fits/frag_sampler.glsl +++ b/src/glsl/webgl2/fits/frag_sampler.glsl @@ -11,7 +11,7 @@ in vec2 frag_uv; uniform sampler2D tex; uniform float opacity; -@include "../hips/color.glsl" +#include ../hips/color.glsl; void main() { vec4 color = texture(tex, frag_uv); diff --git a/src/glsl/webgl2/fits/frag_usampler.glsl b/src/glsl/webgl2/fits/frag_usampler.glsl index 8aeb81fd..cc347932 100644 --- a/src/glsl/webgl2/fits/frag_usampler.glsl +++ b/src/glsl/webgl2/fits/frag_usampler.glsl @@ -11,7 +11,7 @@ in vec2 frag_uv; uniform usampler2D tex; uniform float opacity; -@include "../hips/color.glsl" +#include ../hips/color.glsl; void main() { uvec4 color = texture(tex, frag_uv); diff --git a/src/glsl/webgl2/hips/color.glsl b/src/glsl/webgl2/hips/color.glsl index 52b86f1a..558c9753 100644 --- a/src/glsl/webgl2/hips/color.glsl +++ b/src/glsl/webgl2/hips/color.glsl @@ -17,10 +17,10 @@ uniform float size_tile_uv; uniform int tex_storing_fits; -@include "../colormaps/colormap.glsl" -@include "./transfer_funcs.glsl" -@include "./tonal_corrections.glsl" -@include "./hsv.glsl" +#include ../colormaps/colormap.glsl; +#include ./transfer_funcs.glsl; +#include ./tonal_corrections.glsl; +#include ./hsv.glsl; vec4 get_pixels(vec3 uv) { int idx_texture = int(uv.z); diff --git a/src/glsl/webgl2/hips/color_i.glsl b/src/glsl/webgl2/hips/color_i.glsl index b476a1eb..8bcef344 100644 --- a/src/glsl/webgl2/hips/color_i.glsl +++ b/src/glsl/webgl2/hips/color_i.glsl @@ -17,9 +17,9 @@ uniform float size_tile_uv; uniform int tex_storing_fits; -@include "../colormaps/colormap.glsl" -@include "./transfer_funcs.glsl" -@include "./tonal_corrections.glsl" +#include ../colormaps/colormap.glsl; +#include ./transfer_funcs.glsl; +#include ./tonal_corrections.glsl; ivec4 get_pixels(vec3 uv) { int idx_texture = int(uv.z); diff --git a/src/glsl/webgl2/hips/color_u.glsl b/src/glsl/webgl2/hips/color_u.glsl index 68697d39..7cea1888 100644 --- a/src/glsl/webgl2/hips/color_u.glsl +++ b/src/glsl/webgl2/hips/color_u.glsl @@ -17,9 +17,9 @@ uniform float size_tile_uv; uniform int tex_storing_fits; -@include "../colormaps/colormap.glsl" -@include "./transfer_funcs.glsl" -@include "./tonal_corrections.glsl" +#include ../colormaps/colormap.glsl; +#include ./transfer_funcs.glsl; +#include ./tonal_corrections.glsl; uvec4 get_pixels(vec3 uv) { int idx_texture = int(uv.z); diff --git a/src/glsl/webgl2/hips/rasterizer/color.frag b/src/glsl/webgl2/hips/rasterizer/color.frag index 404df7ee..a970b1bf 100644 --- a/src/glsl/webgl2/hips/rasterizer/color.frag +++ b/src/glsl/webgl2/hips/rasterizer/color.frag @@ -13,7 +13,7 @@ in float m_end; out vec4 out_frag_color; uniform float opacity; -@include "../color.glsl" +#include ../color.glsl; void main() { vec4 color_start = get_color_from_texture(frag_uv_start); diff --git a/src/glsl/webgl2/hips/rasterizer/grayscale_to_colormap.frag b/src/glsl/webgl2/hips/rasterizer/grayscale_to_colormap.frag index 9217edb1..26ec6888 100644 --- a/src/glsl/webgl2/hips/rasterizer/grayscale_to_colormap.frag +++ b/src/glsl/webgl2/hips/rasterizer/grayscale_to_colormap.frag @@ -12,7 +12,7 @@ in float m_end; out vec4 out_frag_color; -@include "../color.glsl" +#include ../color.glsl; uniform float opacity; diff --git a/src/glsl/webgl2/hips/rasterizer/grayscale_to_colormap_i.frag b/src/glsl/webgl2/hips/rasterizer/grayscale_to_colormap_i.frag index 591cdb7d..aa78d645 100644 --- a/src/glsl/webgl2/hips/rasterizer/grayscale_to_colormap_i.frag +++ b/src/glsl/webgl2/hips/rasterizer/grayscale_to_colormap_i.frag @@ -12,7 +12,7 @@ in float m_end; out vec4 out_frag_color; -@include "../color_i.glsl" +#include ../color_i.glsl; uniform float opacity; diff --git a/src/glsl/webgl2/hips/rasterizer/grayscale_to_colormap_u.frag b/src/glsl/webgl2/hips/rasterizer/grayscale_to_colormap_u.frag index d363df3b..b6bf4751 100644 --- a/src/glsl/webgl2/hips/rasterizer/grayscale_to_colormap_u.frag +++ b/src/glsl/webgl2/hips/rasterizer/grayscale_to_colormap_u.frag @@ -13,7 +13,7 @@ in float m_end; out vec4 out_frag_color; -@include "../color_u.glsl" +#include ../color_u.glsl; uniform float opacity; diff --git a/src/glsl/webgl2/hips/rasterizer/raster.vert b/src/glsl/webgl2/hips/rasterizer/raster.vert index aab1e021..4a77577a 100644 --- a/src/glsl/webgl2/hips/rasterizer/raster.vert +++ b/src/glsl/webgl2/hips/rasterizer/raster.vert @@ -23,7 +23,7 @@ uniform float czf; // current time in ms uniform float current_time; -@include "../projection.glsl" +#include ../projection.glsl; void main() { gl_Position = vec4(ndc_pos, 0.0, 1.0); diff --git a/src/glsl/webgl2/hips/raytracer/color.frag b/src/glsl/webgl2/hips/raytracer/color.frag index c57af325..d120de48 100644 --- a/src/glsl/webgl2/hips/raytracer/color.frag +++ b/src/glsl/webgl2/hips/raytracer/color.frag @@ -19,8 +19,8 @@ struct Tile { uniform Tile textures_tiles[12]; uniform int num_tiles; -@include "../color.glsl" -@include "./healpix.glsl" +#include ../color.glsl; +#include ./healpix.glsl; uniform float opacity; diff --git a/src/glsl/webgl2/hips/raytracer/grayscale_to_colormap.frag b/src/glsl/webgl2/hips/raytracer/grayscale_to_colormap.frag index 1e3b8f58..445a2b85 100644 --- a/src/glsl/webgl2/hips/raytracer/grayscale_to_colormap.frag +++ b/src/glsl/webgl2/hips/raytracer/grayscale_to_colormap.frag @@ -25,8 +25,8 @@ struct TileColor { bool found; }; -@include "../color.glsl" -@include "./healpix.glsl" +#include ../color.glsl; +#include ./healpix.glsl; vec4 get_tile_color(vec3 pos) { HashDxDy result = hash_with_dxdy(0, pos.zxy); diff --git a/src/glsl/webgl2/hips/raytracer/grayscale_to_colormap_i.frag b/src/glsl/webgl2/hips/raytracer/grayscale_to_colormap_i.frag index e2e4be65..9773fa44 100644 --- a/src/glsl/webgl2/hips/raytracer/grayscale_to_colormap_i.frag +++ b/src/glsl/webgl2/hips/raytracer/grayscale_to_colormap_i.frag @@ -20,8 +20,8 @@ uniform Tile textures_tiles[12]; uniform float opacity; -@include "../color_i.glsl" -@include "./healpix.glsl" +#include ../color_i.glsl; +#include ./healpix.glsl; vec4 get_tile_color(vec3 pos) { HashDxDy result = hash_with_dxdy(0, pos.zxy); diff --git a/src/glsl/webgl2/hips/raytracer/grayscale_to_colormap_u.frag b/src/glsl/webgl2/hips/raytracer/grayscale_to_colormap_u.frag index 765c799f..9b2b899f 100644 --- a/src/glsl/webgl2/hips/raytracer/grayscale_to_colormap_u.frag +++ b/src/glsl/webgl2/hips/raytracer/grayscale_to_colormap_u.frag @@ -20,8 +20,8 @@ uniform Tile textures_tiles[12]; uniform float opacity; -@include "../color_u.glsl" -@include "./healpix.glsl" +#include ../color_u.glsl; +#include ./healpix.glsl; vec4 get_tile_color(vec3 pos) { HashDxDy result = hash_with_dxdy(0, pos.zxy); diff --git a/src/glsl/webgl2/hips/raytracer/raytracer.vert b/src/glsl/webgl2/hips/raytracer/raytracer.vert index 2954c5b6..1b60b1ce 100644 --- a/src/glsl/webgl2/hips/raytracer/raytracer.vert +++ b/src/glsl/webgl2/hips/raytracer/raytracer.vert @@ -12,7 +12,7 @@ uniform float czf; uniform mat4 model; uniform sampler2D position_tex; -@include "../projection.glsl" +#include ../projection.glsl; void main() { vec2 uv = pos_clip_space * 0.5 + 0.5; diff --git a/src/js/A.js b/src/js/A.js new file mode 100644 index 00000000..0cf0a9d6 --- /dev/null +++ b/src/js/A.js @@ -0,0 +1,311 @@ +// Copyright 2013 - UDS/CNRS +// The Aladin Lite program is distributed under the terms +// of the GNU General Public License version 3. +// +// This file is part of Aladin Lite. +// +// Aladin Lite is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, version 3 of the License. +// +// Aladin Lite is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// The GNU General Public License is available in COPYING file +// along with Aladin Lite. +// + + +/****************************************************************************** + * Aladin Lite project + * + * File Aladin.js (main class) + * Facade to expose Aladin Lite methods + * + * Author: Thomas Boch[CDS] + * + *****************************************************************************/ + +import { MOC } from "./MOC.js"; +import { Overlay } from "./Overlay.js"; +import { Circle } from "./Circle.js"; +import { Ellipse } from "./Ellipse.js"; +import { Polyline } from "./Polyline.js"; +import { Catalog } from "./Catalog.js"; +import { ProgressiveCat } from "./ProgressiveCat.js"; +import { Source } from "./Source.js"; +import { Coo } from "./libs/astro/coo.js"; +import { URLBuilder } from "./URLBuilder.js"; +import { HiPSDefinition } from "./HiPSDefinition.js"; +import { ColorCfg } from './ColorCfg.js'; +import { ObsCore } from "./vo/ObsCore.js"; +import { Aladin } from "./Aladin.js"; +// Wasm top level import +import init, * as module from './../core/pkg'; + +import $ from 'jquery'; + +// Import aladin css inside the project +import './../css/aladin.css'; + +/////////////////////////////// +/////// Aladin Lite API /////// +/////////////////////////////// +let A = {}; + +//// New API //// +// For developers using Aladin lite: all objects should be created through the API, +// rather than creating directly the corresponding JS objects +// This facade allows for more flexibility as objects can be updated/renamed harmlessly + +//@API +A.aladin = function (divSelector, options) { + return new Aladin($(divSelector)[0], options); +}; + +// @API +A.source = function (ra, dec, data, options) { + return new Source(ra, dec, data, options); +}; + +// @API +A.marker = function (ra, dec, options, data) { + options = options || {}; + options['marker'] = true; + return A.source(ra, dec, data, options); +}; + +// @API +A.polygon = function (raDecArray, options) { + const numVertices = raDecArray.length; + + if (numVertices < 3) { + // Cannot define a polygon from that + throw 'Cannot define a polygon from less than 3 vertices'; + } + + const lastVertexIdx = numVertices - 1; + + // User gave a closed polygon, so we remove the last vertex + if (raDecArray[0][0] == raDecArray[lastVertexIdx][0] && raDecArray[0][1] == raDecArray[lastVertexIdx][1]) { + raDecArray.pop() + // but declare the polygon as closed + } + + options = options || {}; + options.closed = true; + + return new Polyline(raDecArray, options); +}; + +//@API +A.polyline = function (raDecArray, options) { + return new Polyline(raDecArray, options); +}; + + +// @API +A.circle = function (ra, dec, radiusDeg, options) { + return new Circle([ra, dec], radiusDeg, options); +}; + +/** + * + * @API + * + * @param ra + * @param dec + * @param radiusRaDeg the radius along the ra axis in degrees + * @param radiusDecDeg the radius along the dec axis in degrees + * @param rotationDeg the rotation angle in degrees + * + */ +A.ellipse = function (ra, dec, radiusRaDeg, radiusDecDeg, rotationDeg, options) { + return new Ellipse([ra, dec], radiusRaDeg, radiusDecDeg, rotationDeg, options); +}; + +// @API +A.graphicOverlay = function (options) { + return new Overlay(options); +}; + +// @API +A.catalog = function (options) { + return new Catalog(options); +}; + +// @API +A.catalogHiPS = function (rootURL, options) { + return new ProgressiveCat(rootURL, null, null, options); +}; + +// API +A.footprintsFromSTCS = function (stcs, options) { + var footprints = Overlay.parseSTCS(stcs, options); + + return footprints; +} + +// API +A.MOCFromURL = function (url, options, successCallback) { + var moc = new MOC(options); + moc.dataFromFITSURL(url, successCallback); + + return moc; +}; + +// API +A.MOCFromJSON = function (jsonMOC, options) { + var moc = new MOC(options); + moc.dataFromJSON(jsonMOC); + + return moc; +}; + + +// TODO: try first without proxy, and then with, if param useProxy not set +// API +A.catalogFromURL = function (url, options, successCallback, errorCallback, useProxy) { + var catalog = A.catalog(options); + + const processVOTable = function (sources, footprints, fields) { + catalog.setFields(fields); + + if (catalog.isObsCore()) { + // The fields corresponds to obscore ones + // Set the name of the catalog to be ObsCore: + catalog.name = "ObsCore:" + url; + } + + // Even if the votable is not a proper ObsCore one, try to see if specific columns are given + // e.g. access_format and access_url + ObsCore.handleActions(catalog); + + catalog.addFootprints(footprints) + catalog.addSources(sources); + + if (successCallback) { + successCallback(sources); + } + }; + + if (useProxy !== undefined) { + Catalog.parseVOTable( + url, + processVOTable, + errorCallback, + catalog.maxNbSources, + useProxy, + catalog.raField, catalog.decField + ); + } else { + Catalog.parseVOTable( + url, + processVOTable, + () => { + console.log("error cors") + Catalog.parseVOTable( + url, + processVOTable, + errorCallback, + catalog.maxNbSources, + true, + catalog.raField, catalog.decField + ); + }, + catalog.maxNbSources, + false, + catalog.raField, catalog.decField + ); + } + + return catalog; +}; + +// API +// @param target: can be either a string representing a position or an object name, or can be an object with keys 'ra' and 'dec' (values being in decimal degrees) +A.catalogFromSimbad = function (target, radius, options, successCallback, errorCallback) { + options = options || {}; + if (!('name' in options)) { + options['name'] = 'Simbad'; + } + var url = URLBuilder.buildSimbadCSURL(target, radius); + return A.catalogFromURL(url, options, successCallback, errorCallback, false); +}; + +// API +A.catalogFromNED = function (target, radius, options, successCallback, errorCallback) { + options = options || {}; + if (!('name' in options)) { + options['name'] = 'NED'; + } + var url; + if (target && (typeof target === "object")) { + if ('ra' in target && 'dec' in target) { + url = URLBuilder.buildNEDPositionCSURL(target.ra, target.dec, radius); + } + } + else { + var isObjectName = /[a-zA-Z]/.test(target); + if (isObjectName) { + url = URLBuilder.buildNEDObjectCSURL(target, radius); + } + else { + var coo = new Coo(); + coo.parse(target); + url = URLBuilder.buildNEDPositionCSURL(coo.lon, coo.lat, radius); + } + } + + return A.catalogFromURL(url, options, successCallback, errorCallback, true); +}; + +// API +A.catalogFromVizieR = function (vizCatId, target, radius, options, successCallback, errorCallback) { + options = options || {}; + if (!('name' in options)) { + options['name'] = 'VizieR:' + vizCatId; + } + + var url = URLBuilder.buildVizieRCSURL(vizCatId, target, radius, options); + return A.catalogFromURL(url, options, successCallback, errorCallback, false); +}; + +// API +A.catalogFromSkyBot = function (ra, dec, radius, epoch, queryOptions, options, successCallback, errorCallback) { + queryOptions = queryOptions || {}; + options = options || {}; + if (!('name' in options)) { + options['name'] = 'SkyBot'; + } + var url = URLBuilder.buildSkyBotCSURL(ra, dec, radius, epoch, queryOptions); + return A.catalogFromURL(url, options, successCallback, errorCallback, false); +}; + +A.hipsDefinitionFromURL = function(url, successCallback) { + HiPSDefinition.fromURL(url, successCallback); +}; + +A.getAvailableListOfColormaps = function() { + return ColorCfg.COLORMAPS; +}; + +A.init = (async () => { + const isWebGL2Supported = document + .createElement('canvas') + .getContext('webgl2'); + + await init(); + // Check for webgl2 support + if (isWebGL2Supported) { + Aladin.wasmLibs.core = module; + } else { + // WebGL1 not supported + // According to caniuse, https://caniuse.com/webgl2, webgl2 is supported by 89% of users + throw "WebGL2 not supported by your browser"; + } +})(); + +export default A; \ No newline at end of file diff --git a/src/js/Aladin.js b/src/js/Aladin.js index 6ea5c690..5f601501 100644 --- a/src/js/Aladin.js +++ b/src/js/Aladin.js @@ -29,26 +29,18 @@ *****************************************************************************/ import { View } from "./View.js"; -import { MOC } from "./MOC.js"; import { Utils } from "./Utils.js"; import { Overlay } from "./Overlay.js"; -import { Circle } from "./Circle.js"; -import { Ellipse } from "./Ellipse.js"; -import { Polyline } from "./Polyline.js"; import { Logger } from "./Logger.js"; -import { Catalog } from "./Catalog.js"; import { ProgressiveCat } from "./ProgressiveCat.js"; import { Sesame } from "./Sesame.js"; import { PlanetaryFeaturesNameResolver } from "./PlanetaryFeaturesNameResolver.js"; import { CooFrameEnum } from "./CooFrameEnum.js"; import { MeasurementTable } from "./MeasurementTable.js"; import { Location } from "./Location.js"; -import { Source } from "./Source.js"; import { ImageSurvey } from "./ImageSurvey.js"; import { Coo } from "./libs/astro/coo.js"; import { CooConversion } from "./CooConversion.js"; -import { URLBuilder } from "./URLBuilder.js"; -import { HiPSDefinition } from "./HiPSDefinition.js"; import { AladinLogo } from "./gui/AladinLogo.js"; import { ProjectionSelector } from "./gui/ProjectionSelector"; import { ProjectionEnum } from "./ProjectionEnum"; @@ -57,18 +49,12 @@ import { CooGrid } from "./gui/CooGrid.js"; import { ContextMenu } from "./gui/ContextMenu"; import { ALEvent } from "./events/ALEvent.js"; import { Color } from './Color.js'; -import { ColorCfg } from './ColorCfg.js'; import { ImageFITS } from "./ImageFITS.js"; -import { SimbadPointer } from "./SimbadPointer.js"; -import { PlanetaryFeaturesPointer } from "./PlanetaryFeaturesPointer.js"; import { DefaultActionsForContextMenu } from "./DefaultActionsForContextMenu.js"; -import { ObsCore } from "./vo/ObsCore.js"; +import A from "./A.js"; import $ from 'jquery'; -// Import aladin css inside the project -import './../css/aladin.css'; - export let Aladin = (function () { // Constructor @@ -1610,98 +1596,6 @@ export let Aladin = (function () { return Aladin; })(); -/////////////////////////////// -/////// Aladin Lite API /////// -/////////////////////////////// -export let A = {}; -export default A; - -//// New API //// -// For developers using Aladin lite: all objects should be created through the API, -// rather than creating directly the corresponding JS objects -// This facade allows for more flexibility as objects can be updated/renamed harmlessly - -//@API -A.aladin = function (divSelector, options) { - return new Aladin($(divSelector)[0], options); -}; - -// @API -A.source = function (ra, dec, data, options) { - return new Source(ra, dec, data, options); -}; - -// @API -A.marker = function (ra, dec, options, data) { - options = options || {}; - options['marker'] = true; - return A.source(ra, dec, data, options); -}; - -// @API -A.polygon = function (raDecArray, options) { - const numVertices = raDecArray.length; - - if (numVertices < 3) { - // Cannot define a polygon from that - throw 'Cannot define a polygon from less than 3 vertices'; - } - - const lastVertexIdx = numVertices - 1; - - // User gave a closed polygon, so we remove the last vertex - if (raDecArray[0][0] == raDecArray[lastVertexIdx][0] && raDecArray[0][1] == raDecArray[lastVertexIdx][1]) { - raDecArray.pop() - // but declare the polygon as closed - } - - options = options || {}; - options.closed = true; - - return new Polyline(raDecArray, options); -}; - -//@API -A.polyline = function (raDecArray, options) { - return new Polyline(raDecArray, options); -}; - - -// @API -A.circle = function (ra, dec, radiusDeg, options) { - return new Circle([ra, dec], radiusDeg, options); -}; - -/** - * - * @API - * - * @param ra - * @param dec - * @param radiusRaDeg the radius along the ra axis in degrees - * @param radiusDecDeg the radius along the dec axis in degrees - * @param rotationDeg the rotation angle in degrees - * - */ -A.ellipse = function (ra, dec, radiusRaDeg, radiusDecDeg, rotationDeg, options) { - return new Ellipse([ra, dec], radiusRaDeg, radiusDecDeg, rotationDeg, options); -}; - -// @API -A.graphicOverlay = function (options) { - return new Overlay(options); -}; - -// @API -A.catalog = function (options) { - return new Catalog(options); -}; - -// @API -A.catalogHiPS = function (rootURL, options) { - return new ProgressiveCat(rootURL, null, null, options); -}; - // @API /* * return a Box GUI element to insert content @@ -1888,150 +1782,4 @@ Aladin.prototype.displayJPG = Aladin.prototype.displayPNG = function (url, optio Aladin.prototype.setReduceDeformations = function (reduce) { this.reduceDeformations = reduce; this.view.requestRedraw(); -} - -// API -A.footprintsFromSTCS = function (stcs, options) { - var footprints = Overlay.parseSTCS(stcs, options); - - return footprints; -} - -// API -A.MOCFromURL = function (url, options, successCallback) { - var moc = new MOC(options); - moc.dataFromFITSURL(url, successCallback); - - return moc; -}; - -// API -A.MOCFromJSON = function (jsonMOC, options) { - var moc = new MOC(options); - moc.dataFromJSON(jsonMOC); - - return moc; -}; - - -// TODO: try first without proxy, and then with, if param useProxy not set -// API -A.catalogFromURL = function (url, options, successCallback, errorCallback, useProxy) { - var catalog = A.catalog(options); - Catalog.parseVOTable( - url, - function (sources, footprints, fields) { - catalog.setFields(fields); - - if (catalog.isObsCore()) { - // The fields corresponds to obscore ones - // Set the name of the catalog to be ObsCore: - catalog.name = "ObsCore:" + url; - - } - - // Even if the votable is not a proper ObsCore one, try to see if specific columns are given - // e.g. access_format and access_url - ObsCore.handleActions(catalog); - - catalog.addFootprints(footprints) - catalog.addSources(sources); - - if (successCallback) { - successCallback(sources); - } - }, - errorCallback, - catalog.maxNbSources, - useProxy, - catalog.raField, catalog.decField - ); - - return catalog; -}; - -// API -// @param target: can be either a string representing a position or an object name, or can be an object with keys 'ra' and 'dec' (values being in decimal degrees) -A.catalogFromSimbad = function (target, radius, options, successCallback, errorCallback) { - options = options || {}; - if (!('name' in options)) { - options['name'] = 'Simbad'; - } - var url = URLBuilder.buildSimbadCSURL(target, radius); - return A.catalogFromURL(url, options, successCallback, errorCallback, false); -}; - -// API -A.catalogFromNED = function (target, radius, options, successCallback, errorCallback) { - options = options || {}; - if (!('name' in options)) { - options['name'] = 'NED'; - } - var url; - if (target && (typeof target === "object")) { - if ('ra' in target && 'dec' in target) { - url = URLBuilder.buildNEDPositionCSURL(target.ra, target.dec, radius); - } - } - else { - var isObjectName = /[a-zA-Z]/.test(target); - if (isObjectName) { - url = URLBuilder.buildNEDObjectCSURL(target, radius); - } - else { - var coo = new Coo(); - coo.parse(target); - url = URLBuilder.buildNEDPositionCSURL(coo.lon, coo.lat, radius); - } - } - - return A.catalogFromURL(url, options, successCallback, errorCallback, true); -}; - -// API -A.catalogFromVizieR = function (vizCatId, target, radius, options, successCallback, errorCallback) { - options = options || {}; - if (!('name' in options)) { - options['name'] = 'VizieR:' + vizCatId; - } - - var url = URLBuilder.buildVizieRCSURL(vizCatId, target, radius, options); - return A.catalogFromURL(url, options, successCallback, errorCallback, false); -}; - -// API -A.catalogFromSkyBot = function (ra, dec, radius, epoch, queryOptions, options, successCallback, errorCallback) { - queryOptions = queryOptions || {}; - options = options || {}; - if (!('name' in options)) { - options['name'] = 'SkyBot'; - } - var url = URLBuilder.buildSkyBotCSURL(ra, dec, radius, epoch, queryOptions); - return A.catalogFromURL(url, options, successCallback, errorCallback, false); -}; - -A.hipsDefinitionFromURL = function(url, successCallback) { - HiPSDefinition.fromURL(url, successCallback); -}; - -A.getAvailableListOfColormaps = function() { - return ColorCfg.COLORMAPS; -}; - -A.init = (async () => { - const isWebGL2Supported = document - .createElement('canvas') - .getContext('webgl2'); - - // Check for webgl2 support - if (isWebGL2Supported) { - const module = await import('./../../pkg-webgl2'); - Aladin.wasmLibs.core = module; - } else { - // WebGL1 not supported - // According to caniuse, https://caniuse.com/webgl2, webgl2 is supported by 89% of users - throw "WebGL2 not supported by your browser"; - } -})(); - -window.A = A; \ No newline at end of file +} \ No newline at end of file diff --git a/src/js/Catalog.js b/src/js/Catalog.js index 32490442..24ffe47f 100644 --- a/src/js/Catalog.js +++ b/src/js/Catalog.js @@ -292,6 +292,7 @@ export let Catalog = (function() { // return an array of Source(s) from a VOTable url // callback function is called each time a TABLE element has been parsed Catalog.parseVOTable = function(url, successCallback, errorCallback, maxNbSources, useProxy, raField, decField) { + console.log(url) VOTable.parse( url, (fields, rows) => { diff --git a/src/js/ImageFITS.js b/src/js/ImageFITS.js index 8e2a78e2..9ee74346 100644 --- a/src/js/ImageFITS.js +++ b/src/js/ImageFITS.js @@ -31,7 +31,6 @@ import { ALEvent } from "./events/ALEvent.js"; import { ColorCfg } from "./ColorCfg.js"; import { ImageLayer } from "./ImageLayer.js"; import { Utils } from "./Utils.js"; -import { Aladin } from "./Aladin.js"; export let ImageFITS = (function () { diff --git a/src/js/ImageSurvey.js b/src/js/ImageSurvey.js index e6f65c70..c567c1b7 100644 --- a/src/js/ImageSurvey.js +++ b/src/js/ImageSurvey.js @@ -158,6 +158,7 @@ export let ImageSurvey = (function () { properties = await HiPSProperties.fetchFromUrl(url) .catch(async (e) => { // url not valid so we try with the id + try { return await HiPSProperties.fetchFromID(id); } catch(e) { diff --git a/src/js/URLBuilder.js b/src/js/URLBuilder.js index 2efa0f45..9a359450 100644 --- a/src/js/URLBuilder.js +++ b/src/js/URLBuilder.js @@ -65,9 +65,11 @@ export let URLBuilder = (function() { } let url = 'https://vizier.unistra.fr/viz-bin/votable?-source=' + vizCatId + '&-c=' + encodeURIComponent(target)+ '&-out.max=' + maxNbSources + '&-c.rd=' + radiusDegrees; - + // request the `s_region` column usually found in ObsCore tables url = url + '&-out.add=s_region'; + // request the `s_fov` column usually found in ObsCore tables + url = url + '&-out.add=s_fov'; return url; //return 'https://vizier.unistra.fr/viz-bin/conesearch/' + vizCatId + '?ra=' + target.ra + '&dec=' + target.dec + '&sr=' + radiusDegrees; @@ -90,8 +92,6 @@ export let URLBuilder = (function() { return url; } - - }; return URLBuilder; diff --git a/src/js/View.js b/src/js/View.js index f0b118a3..684b5b1b 100644 --- a/src/js/View.js +++ b/src/js/View.js @@ -30,6 +30,7 @@ *****************************************************************************/ import { Aladin } from "./Aladin.js"; +import A from "./A.js"; import { Popup } from "./Popup.js"; import { HealpixGrid } from "./HealpixGrid.js"; import { ProjectionEnum } from "./ProjectionEnum.js"; @@ -39,7 +40,6 @@ import { Stats } from "./libs/Stats.js"; import { Circle } from "./Circle.js"; import { Ellipse } from "./Ellipse"; import { Polyline } from "./Polyline.js"; -import { AladinUtils } from "./AladinUtils.js"; import { CooFrameEnum } from "./CooFrameEnum.js"; import { requestAnimFrame } from "./libs/RequestAnimationFrame.js"; import { WebGLCtx } from "./WebGL.js"; @@ -48,7 +48,6 @@ import { ALEvent } from "./events/ALEvent.js"; import { ColorCfg } from "./ColorCfg.js"; import $ from 'jquery'; -import { Line } from "./Line.js"; import { Footprint } from "./Footprint.js"; export let View = (function () { @@ -75,6 +74,7 @@ export let View = (function () { ALEvent.AL_USE_WASM.listenedBy(document.body, function (e) { let callback = e.detail.callback; + callback(self.wasm); }); @@ -1267,98 +1267,7 @@ export let View = (function () { } } - // TODO: optimize this method !! View.prototype.getVisibleCells = function (norder) { - /*var cells = []; // array to be returned - var cornersXY = []; - var nside = Math.pow(2, norder); // TODO : to be modified - var npix = 12 * nside * nside; - var ipixCenter = null; - - // build list of pixels - var pixList = this.getVisiblePixList(norder) - var ipix; - var lon, lat; - var corners; - for (var ipixIdx=0, len=pixList.length; ipixIdx0) { - continue; - } - var cornersXYView = []; - //corners = HealpixCache.corners_nest(ipix, nside); - corners = this.wasm.hpxNestedVertices(Math.log2(nside), ipix); - - for (var k=0; k<4; k++) { - const lon = corners[k*2]; - const lat = corners[k*2 + 1]; - cornersXY[k] = this.wasm.worldToScreen(lon, lat); - } - - if (cornersXY[0] == null || cornersXY[1] == null || cornersXY[2] == null || cornersXY[3] == null ) { - continue; - } - - for (var k=0; k<4; k++) { - //cornersXYView[k] = AladinUtils.xyToView(cornersXY[k].X, cornersXY[k].Y, this.width, this.height, this.largestDim, this.zoomFactor); - cornersXYView[k] = { - vx: cornersXY[k][0], - vy: cornersXY[k][1], - }; - } - - // detect pixels outside view. Could be improved ! - // we minimize here the number of cells returned - if( cornersXYView[0].vx<0 && cornersXYView[1].vx<0 && cornersXYView[2].vx<0 &&cornersXYView[3].vx<0) { - continue; - } - if( cornersXYView[0].vy<0 && cornersXYView[1].vy<0 && cornersXYView[2].vy<0 &&cornersXYView[3].vy<0) { - continue; - } - if( cornersXYView[0].vx>=this.width && cornersXYView[1].vx>=this.width && cornersXYView[2].vx>=this.width &&cornersXYView[3].vx>=this.width) { - continue; - } - if( cornersXYView[0].vy>=this.height && cornersXYView[1].vy>=this.height && cornersXYView[2].vy>=this.height &&cornersXYView[3].vy>=this.height) { - continue; - } - - // New faster approach: when a vertex from a cell gets to the other side of the projection - // its vertices order change from counter-clockwise to clockwise! - // So if the vertices describing a cell are given in clockwise order - // we know it crosses the projection, so we do not plot them! - if (!AladinUtils.counterClockwiseTriangle(cornersXYView[0].vx, cornersXYView[0].vy, cornersXYView[1].vx, cornersXYView[1].vy, cornersXYView[2].vx, cornersXYView[2].vy) || - !AladinUtils.counterClockwiseTriangle(cornersXYView[0].vx, cornersXYView[0].vy, cornersXYView[2].vx, cornersXYView[2].vy, cornersXYView[3].vx, cornersXYView[3].vy)) { - continue; - } - - if (this.projection == ProjectionEnum.HPX) { - const triIdxInCollignonZone = ((p) => { - const x = ((p.vx / this.catalogCanvas.clientWidth) - 0.5) * this.zoomFactor; - const y = ((p.vy / this.catalogCanvas.clientHeight) - 0.5) * this.zoomFactor; - - const xZone = Math.floor((x + 0.5) * 4); - return xZone + 4 * (y > 0.0); - }); - - const isInCollignon = ((p) => { - const y = ((p.vy / this.catalogCanvas.clientHeight) - 0.5) * this.zoomFactor; - - return y < -0.25 || y > 0.25; - }); - - if (isInCollignon(cornersXYView[0]) && isInCollignon(cornersXYView[1]) && isInCollignon(cornersXYView[2]) && isInCollignon(cornersXYView[3])) { - const allVerticesInSameCollignonRegion = (triIdxInCollignonZone(cornersXYView[0]) == triIdxInCollignonZone(cornersXYView[1])) && (triIdxInCollignonZone(cornersXYView[0]) == triIdxInCollignonZone(cornersXYView[2])) && (triIdxInCollignonZone(cornersXYView[0]) == triIdxInCollignonZone(cornersXYView[3])); - if (!allVerticesInSameCollignonRegion) { - continue; - } - } - } - - cornersXYView.ipix = ipix; - cells.push(cornersXYView); - } - - return cells;*/ return this.wasm.getVisibleCells(norder); }; diff --git a/vite.config.js b/vite.config.js new file mode 100644 index 00000000..c0f43a0c --- /dev/null +++ b/vite.config.js @@ -0,0 +1,48 @@ +import { resolve } from 'path' +import { defineConfig } from 'vite'; + +// plugins +// For wasm inclusion +import wasm from "vite-plugin-wasm"; +import topLevelAwait from "vite-plugin-top-level-await"; +// For wasm genrated by wasm-pack +import wasmPack from 'vite-plugin-wasm-pack'; + +// To include and minify glsl into the bundle +import glsl from 'vite-plugin-glsl'; + +// To include css into the bundle +import cssInjectedByJsPlugin from 'vite-plugin-css-injected-by-js' + +export default defineConfig({ + build: { + minify: 'esbuild', + lib: { + // Could also be a dictionary or array of multiple entry points + entry: resolve(__dirname, 'src/js/A.js'), + name: 'A', + // the proper extensions will be added + fileName: 'aladin', + }, + rollupOptions: {}, + //formats: ["es"], + //target: ["es2015"], + // Relative to the root + outDir: resolve(__dirname, 'dist'), + }, + //publicDir: resolve(__dirname, 'src/img'), + plugins: [ + wasm(), + wasmPack(resolve(__dirname, 'src/core')), + topLevelAwait(), + glsl({ + compress: true, + }), + cssInjectedByJsPlugin(), + ], + server: { + host: '0.0.0.0', + port: '8080', + open: '/examples/index.html', + }, +}); \ No newline at end of file