mirror of
https://github.com/cds-astro/aladin-lite.git
synced 2025-12-31 23:18:08 -08:00
Compare commits
8 Commits
source-col
...
feat-keep-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
45845fad02 | ||
|
|
01cbb149c1 | ||
|
|
ea83e2b199 | ||
|
|
9922690355 | ||
|
|
3b926fe5a0 | ||
|
|
d82ab61a2f | ||
|
|
e548aec016 | ||
|
|
e6818af3b0 |
191
CHANGELOG.md
191
CHANGELOG.md
@@ -1,38 +1,113 @@
|
||||
# Changelogs
|
||||
|
||||
## unreleased
|
||||
## Unreleased
|
||||
|
||||
* [fix] request a redraw after adding an array of footprints [PR #218]
|
||||
### What's Changed
|
||||
|
||||
## 3.5.1-beta
|
||||
* [perf] perform CPU computations with Vec3 and Matrix3 and not 4 dimensions matrices/vectors
|
||||
* [feat] lockNorthUp Aladin object new option locking the north pole up to the view center
|
||||
|
||||
## Released
|
||||
|
||||
### 3.6.3
|
||||
|
||||
#### What's Changed
|
||||
|
||||
* [maint] remove Shift shorcut for triggering rectangular source selection. Shortcuts will be implemented later. by [@bmatthieu3][bmatthieu3] in <https://github.com/cds-astro/aladin-lite/pull/269>
|
||||
* [fix] decide to show the contextual menu only if user has not right click while moving more than 10px. by [@bmatthieu3][bmatthieu3] in <https://github.com/cds-astro/aladin-lite/pull/269>
|
||||
* [fix] CSS selector took the whole div in smartphone usage. by [@bmatthieu3][bmatthieu3] in <https://github.com/cds-astro/aladin-lite/pull/269>
|
||||
* [fix] smartphone 2 fingers zoom pinching around the 180deg meridian. by [@bmatthieu3][bmatthieu3] in <https://github.com/cds-astro/aladin-lite/pull/269>
|
||||
* [fix] use copy2Clipboard utils functions from contextual menu. by [@bmatthieu3][bmatthieu3] in <https://github.com/cds-astro/aladin-lite/pull/269>
|
||||
* [fix] improved ID/HiPS url detection (retry if a relative path to a local HiPS is given as it is considered as an ID). by [@bmatthieu3][bmatthieu3] in <https://github.com/cds-astro/aladin-lite/pull/269>
|
||||
|
||||
### 3.6.1
|
||||
|
||||
#### What's Changed
|
||||
* [feat] AVM tags support found in jpeg headers by [@bmatthieu3][bmatthieu3] in <https://github.com/cds-astro/aladin-lite/pull/178>
|
||||
* [feat] Merge remove overlay by name to Develop by [@Xen0Xys][Xen0Xys] in <https://github.com/cds-astro/aladin-lite/pull/182>
|
||||
* [fix] Restore A.footprint function by [@szpetny][szpetny] in <https://github.com/cds-astro/aladin-lite/pull/183>
|
||||
* [testing] Merge playwright tests to Develop by [@Xen0Xys][Xen0Xys] in <https://github.com/cds-astro/aladin-lite/pull/176>
|
||||
* [fix] Version 3.5.1 by [@bmatthieu3][bmatthieu3] in <https://github.com/cds-astro/aladin-lite/pull/180>
|
||||
* [fix] Also add style sheet in shadow dom context by [@ManonMarchand][ManonMarchand] in <https://github.com/cds-astro/aladin-lite/pull/194>
|
||||
* [feat] Add selectionColor, onClick to catalog parameters handled by updateShape by [@simontorres][simontorres] in <https://github.com/cds-astro/aladin-lite/pull/198>
|
||||
* [feat] HiPS cube support by [@bmatthieu3][bmatthieu3] in <https://github.com/cds-astro/aladin-lite/pull/204>
|
||||
* [feat] PolySelect implementation and miscellaneous selection improvements by [@pmatsson][pmatsson] in <https://github.com/cds-astro/aladin-lite/pull/195>
|
||||
* [fix] Request a redraw after adding an array of footprints by [@ManonMarchand][ManonMarchand] in <https://github.com/cds-astro/aladin-lite/pull/218>
|
||||
* [fix] Circle opacity not working by [@tboch][tboch] in <https://github.com/cds-astro/aladin-lite/pull/222>
|
||||
* [fix] Bug introduced in #218 by [@ManonMarchand][ManonMarchand] in <https://github.com/cds-astro/aladin-lite/pull/223>
|
||||
* [fix] CSS style for canvas element is more selective by [@tboch][tboch] in <https://github.com/cds-astro/aladin-lite/pull/224>
|
||||
* [maint] Add zenodo.json file by [@ManonMarchand][ManonMarchand] in <https://github.com/cds-astro/aladin-lite/pull/226>
|
||||
* [maint] Remove old files using jquery by [@cquiroz][cquiroz] in <https://github.com/cds-astro/aladin-lite/pull/231>
|
||||
* [fix] Display of HiPS with maxOrder = 0 by [@bmatthieu3][bmatthieu3] in <https://github.com/cds-astro/aladin-lite/pull/236>
|
||||
* [fix] Combine requestedOptions and Aladin.DEFAULT_OPTIONS with spread operator by [@pcuste1][pcuste1] in <https://github.com/cds-astro/aladin-lite/pull/237>
|
||||
* [fix] Add back cmap reverse checkbox by [@bmatthieu3][bmatthieu3] in <https://github.com/cds-astro/aladin-lite/pull/238>
|
||||
* [fix] JPEG draw black screen when tiles are missing by [@bmatthieu3][bmatthieu3] in <https://github.com/cds-astro/aladin-lite/pull/246>
|
||||
* [fix] Filled moc drawing reverse longitude by [@bmatthieu3][bmatthieu3] in <https://github.com/cds-astro/aladin-lite/pull/250>
|
||||
* [doc] Deprecate longitudeReversed HiPS options property by [@bmatthieu3][bmatthieu3] in <https://github.com/cds-astro/aladin-lite/pull/251>
|
||||
* [fix] Stop contextmenu event propagation only if context menu enabled by [@alexgoff][alexgoff] in <https://github.com/cds-astro/aladin-lite/pull/259>
|
||||
* [ui] Minor fixes and enhancements by [@bmatthieu3][bmatthieu3] in <https://github.com/cds-astro/aladin-lite/pull/256>
|
||||
* [fix] Handle NaNs by the GPU (fix for windows) by [@bmatthieu3][bmatthieu3] in <https://github.com/cds-astro/aladin-lite/pull/254>
|
||||
* [fix] Grid labels formatting by [@bmatthieu3][bmatthieu3] in <https://github.com/cds-astro/aladin-lite/pull/261>
|
||||
* [feat] Shape function given to a catalog by [@bmatthieu3][bmatthieu3] in <https://github.com/cds-astro/aladin-lite/pull/262>
|
||||
* [fix] Tooltip pos out of fov by [@bmatthieu3][bmatthieu3] in <https://github.com/cds-astro/aladin-lite/pull/263>
|
||||
* [fix] MOC settings after its creation by [@bmatthieu3][bmatthieu3] in <https://github.com/cds-astro/aladin-lite/pull/265>
|
||||
* [fix] ICRS to FK5J2000 cooframe renaming by [@bmatthieu3][bmatthieu3] in <https://github.com/cds-astro/aladin-lite/pull/264>
|
||||
* [fix] Revert #264 by [@bmatthieu3][bmatthieu3] in <https://github.com/cds-astro/aladin-lite/pull/268>
|
||||
|
||||
#### New Contributors
|
||||
* [@cquiroz][cquiroz] made their first contribution in <https://github.com/cds-astro/aladin-lite/pull/231>
|
||||
* [@pcuste1][pcuste1] made their first contribution in <https://github.com/cds-astro/aladin-lite/pull/237>
|
||||
* [@alexgoff][alexgoff] made their first contribution in <https://github.com/cds-astro/aladin-lite/pull/259>
|
||||
|
||||
**Full Changelog**: <https://github.com/cds-astro/aladin-lite/compare/3.4.5...3.6.1>
|
||||
|
||||
### 3.6.1-beta
|
||||
|
||||
#### What's Changed
|
||||
* [feat] Add selectionColor, onClick to catalog parameters handled by updateShape by [@simontorres][simontorres] in <https://github.com/cds-astro/aladin-lite/pull/198>
|
||||
* [feat] HiPS cube support by [@bmatthieu3][bmatthieu3] in <https://github.com/cds-astro/aladin-lite/pull/204>
|
||||
* [feat] PolySelect implementation and miscellaneous selection improvements by [@pmatsson][pmatsson] in <https://github.com/cds-astro/aladin-lite/pull/195>
|
||||
* [fix] Request a redraw after adding an array of footprints by [@ManonMarchand][ManonMarchand] in <https://github.com/cds-astro/aladin-lite/pull/218>
|
||||
* [fix] Circle opacity not working by [@tboch][tboch] in <https://github.com/cds-astro/aladin-lite/pull/222>
|
||||
* [fix] Bug introduced in #218 by [@ManonMarchand][ManonMarchand] in <https://github.com/cds-astro/aladin-lite/pull/223>
|
||||
* [fix] CSS style for canvas element is more selective by [@tboch][tboch] in <https://github.com/cds-astro/aladin-lite/pull/224>
|
||||
* [maint] add zenodo.json file by [@ManonMarchand][ManonMarchand] in <https://github.com/cds-astro/aladin-lite/pull/226>
|
||||
* [maint] Remove old files using jquery by [@cquiroz][cquiroz] in <https://github.com/cds-astro/aladin-lite/pull/231>
|
||||
|
||||
#### New Contributors
|
||||
* [@cquiroz][cquiroz] made their first contribution in <https://github.com/cds-astro/aladin-lite/pull/231>
|
||||
|
||||
**Full Changelog**: <https://github.com/cds-astro/aladin-lite/compare/3.5.1-beta...3.6.1-beta>
|
||||
|
||||
### 3.5.1-beta
|
||||
|
||||
* [feat] Add support for name removing in `removeOverlay` method
|
||||
* [test] Add support of playwright. Instructions in the readme for running the test matching snapshots [PR #176]
|
||||
* [fix] Order of overlays in the stack now matches the addMOC/addCatalog/addOverlay calls ordering
|
||||
* [doc] Expose the API of Coo class
|
||||
* [fix] Insert aladin css inside the aladin lite so that it should be compliant with the use of shadow DOMs [cds-astro/ipyaladin#113], [marimo-team/marimo#2106]
|
||||
* [feat] Add possibility of giving a local JS FileList to load a locally-stored HiPS without starting an HTTP server [cds-astro/aladin-lite#103]
|
||||
* [feat] Add possibility of giving a local JS FileList to load a locally-stored HiPS without starting an HTTP server <https://github.com/cds-astro/aladin-lite/pull/103>
|
||||
* [fix] removeOverlayByName
|
||||
|
||||
## 3.5.0-beta
|
||||
### 3.5.0-beta
|
||||
|
||||
* [enhancement] add `options.colnames` to A.catalogFromVizieR to tell VizieR we want absolutely want to retrieve specific columns
|
||||
* [feat] provide a new drawAxes option to A.ellipse. This is useful for plotting error ellipsis.
|
||||
|
||||
## 3.4.5-beta
|
||||
### 3.4.5-beta
|
||||
|
||||
* [feat] add `layerChanged` event when a layer is added or removed
|
||||
* [deprecate] of `select` event, use `objectsSelected` event instead
|
||||
* [ui] add the ability to switch the tile format to download
|
||||
|
||||
## 3.4.3-beta
|
||||
### 3.4.3-beta
|
||||
|
||||
* [bugfix] zoom control buttons
|
||||
* [feat] save a MOC as a JSON file from the UI <https://github.com/cds-astro/aladin-lite/issues/154>
|
||||
* [feat] save a source selection from the measurement table as a CSV file
|
||||
* [feat] allow to display jpeg/jpg images with a wcs passed as a JS dictionary: <https://github.com/cds-astro/aladin-lite/issues/173>
|
||||
|
||||
## 3.4.2-beta
|
||||
### 3.4.2-beta
|
||||
|
||||
* [impr] Improve smartphone support by setting media queries + a better logic for deploying the contextual menu sub options.
|
||||
* [impr] Improve `WCS` view export with 3rd euler rotation encoding: <https://github.com/cds-astro/aladin-lite/issues/170>. Still some cases are to be handled like: crval on the equator or cylindrical with a galactic frame rotation.
|
||||
@@ -40,21 +115,21 @@
|
||||
* [feat] Add new method `Aladin#getViewImageBuffer` to get the current view as a PNG buffer
|
||||
* [feat] New line rasterizer using GL instancing. This enhances the rendering speed of MOCs.
|
||||
|
||||
## 3.3.3
|
||||
### 3.3.3
|
||||
|
||||
* [feat] UI: add HiPS basic filter that filters the `hipsList` given
|
||||
* [feat] New `hipsList` option parameter when instancing a new Aladin object.
|
||||
* [feat] Zoom smoothing using hermite cubic interpolation functions
|
||||
* [feat] shape option of Catalog and ProgressiveCat accepts a function returning a Footprint. This allow user to
|
||||
associate a footprint to a specific source
|
||||
* [feat] Hover color support by @pmatsson and @bmatthieu3 in <https://github.com/cds-astro/aladin-lite/pull/145>
|
||||
* [feat] Hover color support by [@pmatsson][pmatsson] and [@bmatthieu3][bmatthieu3] in <https://github.com/cds-astro/aladin-lite/pull/145>
|
||||
|
||||
## 3.3.2
|
||||
### 3.3.2
|
||||
|
||||
* [fixed] do not allow to query the properties several times for an imageHiPS
|
||||
* [fixed] Detecting raytracing rendering mode. Adapt the rendering mode in function of the fov value and the projection used. Some projections do have more distortions with wide FoVs so it is better to use the raytracing rendering mode when fov >= smaller FoV threshold.
|
||||
|
||||
## 3.3.0
|
||||
### 3.3.0
|
||||
|
||||
* [fixed] multiple calls to setImageSurvey with the same survey object led to strange behaviour.
|
||||
* [perf] Display the first tile received instantly with no blending. Should enhance the slow reported in issue #88.
|
||||
@@ -75,61 +150,61 @@
|
||||
* [fixed] The parameters `gridColor` and `gridOpacity`, `gridOptions.showLabels` now work as expected
|
||||
* New documentation API (W.I.P) here: <https://cds-astro.github.io/aladin-lite/>
|
||||
* New release page here: <https://aladin.cds.unistra.fr/AladinLite/doc/release/>
|
||||
* A major UI update by @bmatthieu3
|
||||
* A major UI update by [@bmatthieu3][bmatthieu3]
|
||||
1. Some API new classes A.box, A.button
|
||||
2. A status bar where the user can enque messages for a specific amount of time (Aladin.addStatusBarMessage)
|
||||
* Remove of JQuery and autocompletejs dependencies by @bmatthieu3
|
||||
* Fix some performances issues, i.e. a bug when resizing the aladin lite view and which launched several parallel requestAnimationFrame by @bmatthieu3
|
||||
* Remove of JQuery and autocompletejs dependencies by [@bmatthieu3][bmatthieu3]
|
||||
* Fix some performances issues, i.e. a bug when resizing the aladin lite view and which launched several parallel requestAnimationFrame by [@bmatthieu3][bmatthieu3]
|
||||
* Polygon and circular selection (see Aladin class API documentation for how to use it)
|
||||
* ObsCore and Datalink votable parsing and interpretation. This work is still in progress and made in the frame of the SKA radio mission by @bmatthieu3 in <https://github.com/cds-astro/aladin-lite/pull/116>
|
||||
* SODA service query window formular by @bmatthieu3 in <https://github.com/cds-astro/aladin-lite/pull/116>
|
||||
* read only catalog option by @szpetny in <https://github.com/cds-astro/aladin-lite/pull/117>
|
||||
* Small changed regarding drawing a footprint by @szpetny in <https://github.com/cds-astro/aladin-lite/pull/118>
|
||||
* Object and footprint click/hover events expose mouse coordinates by @szpetny in <https://github.com/cds-astro/aladin-lite/pull/121>
|
||||
* A proposal of a new feature - fill the polygon with a color by @szpetny in <https://github.com/cds-astro/aladin-lite/pull/122>
|
||||
* update getViewWCS to adapt to projection by @ManonMarchand in <https://github.com/cds-astro/aladin-lite/pull/119>
|
||||
* New SAMP support by @bmatthieu3 in <https://github.com/cds-astro/aladin-lite/pull/128>
|
||||
* A possibility to create Coo and Footprint objects by @szpetny in <https://github.com/cds-astro/aladin-lite/pull/130>
|
||||
* ObsCore and Datalink votable parsing and interpretation. This work is still in progress and made in the frame of the SKA radio mission by [@bmatthieu3][bmatthieu3] in <https://github.com/cds-astro/aladin-lite/pull/116>
|
||||
* SODA service query window formular by [@bmatthieu3][bmatthieu3] in <https://github.com/cds-astro/aladin-lite/pull/116>
|
||||
* read only catalog option by [@szpetny][szpetny] in <https://github.com/cds-astro/aladin-lite/pull/117>
|
||||
* Small changed regarding drawing a footprint by [@szpetny][szpetny] in <https://github.com/cds-astro/aladin-lite/pull/118>
|
||||
* Object and footprint click/hover events expose mouse coordinates by [@szpetny][szpetny] in <https://github.com/cds-astro/aladin-lite/pull/121>
|
||||
* A proposal of a new feature - fill the polygon with a color by [@szpetny][szpetny] in <https://github.com/cds-astro/aladin-lite/pull/122>
|
||||
* update getViewWCS to adapt to projection by [@ManonMarchand][ManonMarchand] in <https://github.com/cds-astro/aladin-lite/pull/119>
|
||||
* New SAMP support by [@bmatthieu3][bmatthieu3] in <https://github.com/cds-astro/aladin-lite/pull/128>
|
||||
* A possibility to create Coo and Footprint objects by [@szpetny][szpetny] in <https://github.com/cds-astro/aladin-lite/pull/130>
|
||||
* new method aladin.getFrame() that returns the name of the current coordinate system
|
||||
* `getViewWCS` now adapts to the `cooFrame` and the `projection`
|
||||
* `getFov` is no longer capped at 180°
|
||||
* bugfix `setProjection` now also updates for 'PAR' and 'SFL' projections
|
||||
|
||||
## 3.2.0
|
||||
### 3.2.0
|
||||
|
||||
* MOC rendering perf enhanced. Possibility to draw only the perimeter of a MOC object (perimeter set to True)
|
||||
* Many fixes e.g. footprint rendering for all sky projections
|
||||
* A line/shape webgl rasterizer thanks to the use of the `lyon`crate. MOCs and grid lines are rendered that way. Therefore, it is possible to change the grid lines thickness
|
||||
* Use of vite for the project management and deployment
|
||||
|
||||
## 3.1.0
|
||||
### 3.1.0
|
||||
|
||||
* Add message for safari users to enable WebGL2 feature and reload the page by @bmatthieu3 in <https://github.com/cds-astro/aladin-lite/pull/54>
|
||||
* Starting fits support by @bmatthieu3 in <https://github.com/cds-astro/aladin-lite/pull/70>
|
||||
* display fits images with the drag and drop by @bmatthieu3
|
||||
* Add message for safari users to enable WebGL2 feature and reload the page by [@bmatthieu3][bmatthieu3] in <https://github.com/cds-astro/aladin-lite/pull/54>
|
||||
* Starting fits support by [@bmatthieu3][bmatthieu3] in <https://github.com/cds-astro/aladin-lite/pull/70>
|
||||
* display fits images with the drag and drop by [@bmatthieu3][bmatthieu3]
|
||||

|
||||
* support `webp` tile format by @bmatthieu3 and @tboch
|
||||
* planetary name resolver by @tboch
|
||||
* small ui changes and bug fixes by @bmatthieu3
|
||||
* add codemeta and its validatior action by @ManonMarchand in <https://github.com/cds-astro/aladin-lite/pull/66>
|
||||
* support `webp` tile format by [@bmatthieu3][bmatthieu3] and [@tboch][tboch]
|
||||
* planetary name resolver by [@tboch][tboch]
|
||||
* small ui changes and bug fixes by [@bmatthieu3][bmatthieu3]
|
||||
* add codemeta and its validatior action by [@ManonMarchand][ManonMarchand] in <https://github.com/cds-astro/aladin-lite/pull/66>
|
||||
|
||||
## 3.0.0
|
||||
### 3.0.0
|
||||
|
||||
Official release of Aladin Lite v3, [as announced in CDS news](https://cds.unistra.fr/news.php?fn_mode=fullnews&fn_incl=0&fn_id=958).
|
||||
|
||||
* Fix missing tiles issue by @tboch in <https://github.com/cds-astro/aladin-lite/pull/18>
|
||||
* Hips catalogue filtering by @tboch in <https://github.com/cds-astro/aladin-lite/pull/28>
|
||||
* Make footprint selection easier by @tboch in <https://github.com/cds-astro/aladin-lite/pull/19>
|
||||
* Bug fix: enable different colors for multiple polylines in same layer by @tboch in <https://github.com/cds-astro/aladin-lite/pull/30>
|
||||
* Method remove to delete individual source from a catalogue layer by @tboch in <https://github.com/cds-astro/aladin-lite/pull/37>
|
||||
* Stop animation by @tboch in <https://github.com/cds-astro/aladin-lite/pull/40>
|
||||
* Add message for safari users to enable WebGL2 feature and reload the page by @bmatthieu3 in <https://github.com/cds-astro/aladin-lite/pull/54>
|
||||
* Fix missing tiles issue by [@tboch][tboch] in <https://github.com/cds-astro/aladin-lite/pull/18>
|
||||
* Hips catalogue filtering by [@tboch][tboch] in <https://github.com/cds-astro/aladin-lite/pull/28>
|
||||
* Make footprint selection easier by [@tboch][tboch] in <https://github.com/cds-astro/aladin-lite/pull/19>
|
||||
* Bug fix: enable different colors for multiple polylines in same layer by [@tboch][tboch] in <https://github.com/cds-astro/aladin-lite/pull/30>
|
||||
* Method remove to delete individual source from a catalogue layer by [@tboch][tboch] in <https://github.com/cds-astro/aladin-lite/pull/37>
|
||||
* Stop animation by [@tboch][tboch] in <https://github.com/cds-astro/aladin-lite/pull/40>
|
||||
* Add message for safari users to enable WebGL2 feature and reload the page by [@bmatthieu3][bmatthieu3] in <https://github.com/cds-astro/aladin-lite/pull/54>
|
||||
|
||||
## 2.x.x
|
||||
## Version: 2.x.x
|
||||
|
||||
### 2020-08
|
||||
|
||||
* polyline improvements (by @imbasimba)
|
||||
* polyline improvements (by [@imbasimba][imbasimba])
|
||||
|
||||
### 2020-07
|
||||
|
||||
@@ -394,3 +469,33 @@ New in the API:
|
||||
|
||||
* ajout catalogue progressif
|
||||
* ajout on select, objectClicked, objectHovered
|
||||
|
||||
|
||||
## Contributors
|
||||
|
||||
Aladin Lite is made possible thanks to those people:
|
||||
|
||||
* [@alexgoff][alexgoff]
|
||||
* [@bmatthieu3][bmatthieu3]
|
||||
* [@cquiroz][cquiroz]
|
||||
* [@imbasimba][imbasimba]
|
||||
* [@ManonMarchand][ManonMarchand]
|
||||
* [@pcuste1][pcuste1]
|
||||
* [@pmatsson][pmatsson]
|
||||
* [@simontorres][simontorres]
|
||||
* [@szpetny][szpetny]
|
||||
* [@tboch][tboch]
|
||||
* [@Xen0Xys][Xen0Xys]
|
||||
|
||||
[alexgoff]: https://github.com/alexgoff
|
||||
[bmatthieu3]: https://github.com/bmatthieu3
|
||||
[cquiroz]: https://github.com/cquiroz
|
||||
[imbasimba]: https://github.com/imbasimba
|
||||
[ManonMarchand]: https://github.com/ManonMarchand
|
||||
[pcuste1]: https://github.com/pcuste1
|
||||
[pmatsson]: https://github.com/pmatsson
|
||||
[simontorres]: https://github.com/simontorres
|
||||
[szpetny]: https://github.com/szpetny
|
||||
[tboch]: https://github.com/tboch
|
||||
[Xen0Xys]: https://github.com/Xen0Xys
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ A new [API technical documentation](https://cds-astro.github.io/aladin-lite/) is
|
||||
|
||||
[](https://github.com/cds-astro/aladin-lite/actions/workflows/test.yml)
|
||||
[](https://cds-astro.github.io/aladin-lite)
|
||||
[](https://aladin.cds.unistra.fr/AladinLite/doc/release/)
|
||||
[](https://aladin.cds.unistra.fr/AladinLite/doc/release/)
|
||||
|
||||
Aladin Lite is available [at this link](https://aladin.u-strasbg.fr/AladinLite).
|
||||
|
||||
|
||||
@@ -29,17 +29,9 @@
|
||||
showCooGrid: true,
|
||||
fullScreen: true,
|
||||
samp: true,
|
||||
lockNorthUp: true,
|
||||
}
|
||||
);
|
||||
|
||||
/*let id;
|
||||
aladin.on("zoomChanged", () => {
|
||||
if (id)
|
||||
clearTimeout(id);
|
||||
id = setTimeout(() => {
|
||||
console.log("wheel stopped, new cone search here")
|
||||
}, 500);
|
||||
})*/
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"homepage": "https://aladin.u-strasbg.fr/",
|
||||
"name": "aladin-lite",
|
||||
"type": "module",
|
||||
"version": "3.6.4",
|
||||
"version": "3.7.0-beta",
|
||||
"description": "An astronomical HiPS visualizer in the browser",
|
||||
"author": "Thomas Boch and Matthieu Baumann",
|
||||
"license": "GPL-3",
|
||||
|
||||
@@ -3,7 +3,7 @@ name = "aladin-lite"
|
||||
description = "Aladin Lite v3 introduces a new graphical engine written in Rust with the use of WebGL"
|
||||
license = "BSD-3-Clause"
|
||||
repository = "https://github.com/cds-astro/aladin-lite"
|
||||
version = "3.6.4"
|
||||
version = "3.7.0"
|
||||
authors = [ "baumannmatthieu0@gmail.com", "matthieu.baumann@astro.unistra.fr",]
|
||||
edition = "2018"
|
||||
|
||||
@@ -88,4 +88,4 @@ codegen-units = 16
|
||||
rpath = false
|
||||
|
||||
[package.metadata.wasm-pack.profile.release]
|
||||
wasm-opt = true
|
||||
wasm-opt = false
|
||||
|
||||
@@ -1,45 +1,37 @@
|
||||
use cgmath::Matrix4;
|
||||
use cgmath::Matrix3;
|
||||
|
||||
const GAL2ICRS: &'static Matrix4<f64> = &Matrix4::new(
|
||||
const GAL2ICRS: &'static Matrix3<f64> = &Matrix3::new(
|
||||
-0.44482972122205372312012370920248,
|
||||
0.74698218398450941835110635824212,
|
||||
0.49410943719710765017955928850141,
|
||||
0.0,
|
||||
|
||||
-0.19807633727507056817237662907031,
|
||||
0.45598381369115237931077906137440,
|
||||
-0.86766613755716255824577781583414,
|
||||
0.0,
|
||||
|
||||
-0.87343705195577915249273984034980,
|
||||
-0.48383507361641838378786914298189,
|
||||
-0.05487565771261968232908806948676,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
1.0,
|
||||
);
|
||||
|
||||
const ICRS2GAL: &'static Matrix4<f64> = &Matrix4::new(
|
||||
const ICRS2GAL: &'static Matrix3<f64> = &Matrix3::new(
|
||||
-0.44482972122205372312012370920248,
|
||||
-0.19807633727507056817237662907031,
|
||||
-0.87343705195577915249273984034980,
|
||||
0.0,
|
||||
|
||||
0.74698218398450941835110635824212,
|
||||
0.45598381369115237931077906137440,
|
||||
-0.48383507361641838378786914298189,
|
||||
0.0,
|
||||
|
||||
0.49410943719710765017955928850141,
|
||||
-0.86766613755716255824577781583414,
|
||||
-0.05487565771261968232908806948676,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
1.0,
|
||||
);
|
||||
|
||||
const ID: &'static Matrix4<f64> = &Matrix4::new(
|
||||
1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0,
|
||||
const ID: &'static Matrix3<f64> = &Matrix3::new(
|
||||
1.0, 0.0, 0.0,
|
||||
0.0, 1.0, 0.0,
|
||||
0.0, 0.0, 1.0,
|
||||
);
|
||||
|
||||
|
||||
@@ -56,7 +48,7 @@ pub const NUM_COOSYSTEM: usize = 2;
|
||||
|
||||
impl CooSystem {
|
||||
#[inline]
|
||||
pub fn to(&self, coo_system: Self) -> &Matrix4<f64> {
|
||||
pub fn to(&self, coo_system: Self) -> &Matrix3<f64> {
|
||||
match (self, coo_system) {
|
||||
(CooSystem::GAL, CooSystem::ICRS) => GAL2ICRS,
|
||||
(CooSystem::ICRS, CooSystem::GAL) => ICRS2GAL,
|
||||
|
||||
@@ -218,19 +218,19 @@ impl UniformType for Matrix2<f32> {
|
||||
}
|
||||
}
|
||||
|
||||
use cgmath::Matrix4;
|
||||
impl UniformType for Matrix4<f32> {
|
||||
use cgmath::Matrix3;
|
||||
impl UniformType for Matrix3<f32> {
|
||||
fn uniform(gl: &WebGlContext, location: Option<&WebGlUniformLocation>, value: &Self) {
|
||||
gl.uniform_matrix4fv_with_f32_array(location, false, value.as_ref() as &[f32; 16]);
|
||||
gl.uniform_matrix3fv_with_f32_array(location, false, value.as_ref() as &[f32; 9]);
|
||||
}
|
||||
}
|
||||
use crate::Abort;
|
||||
|
||||
impl UniformType for Matrix4<f64> {
|
||||
impl UniformType for Matrix3<f64> {
|
||||
fn uniform(gl: &WebGlContext, location: Option<&WebGlUniformLocation>, value: &Self) {
|
||||
// Cast the matrix
|
||||
let mat_f32 = value.cast::<f32>().unwrap_abort();
|
||||
gl.uniform_matrix4fv_with_f32_array(location, false, mat_f32.as_ref() as &[f32; 16]);
|
||||
gl.uniform_matrix3fv_with_f32_array(location, false, mat_f32.as_ref() as &[f32; 9]);
|
||||
}
|
||||
}
|
||||
use super::texture::Texture2D;
|
||||
|
||||
@@ -35,7 +35,6 @@ use al_api::{
|
||||
grid::GridCfg,
|
||||
hips::{HiPSCfg, ImageMetadata},
|
||||
};
|
||||
use cgmath::Vector4;
|
||||
use fitsrs::{fits::AsyncFits, hdu::extension::AsyncXtensionHDU};
|
||||
|
||||
use web_sys::{HtmlElement, WebGl2RenderingContext};
|
||||
@@ -75,6 +74,7 @@ pub struct App {
|
||||
// Task executor
|
||||
//exec: Rc<RefCell<TaskExecutor>>,
|
||||
inertia: Option<Inertia>,
|
||||
north_up: bool,
|
||||
disable_inertia: Rc<RefCell<bool>>,
|
||||
dist_dragging: f32,
|
||||
time_start_dragging: Time,
|
||||
@@ -172,7 +172,7 @@ impl App {
|
||||
//let tasks_finished = false;
|
||||
let request_redraw = false;
|
||||
let rendering = true;
|
||||
let prev_cam_position = camera.get_center().truncate();
|
||||
let prev_cam_position = *camera.get_center();
|
||||
//let prev_center = Vector3::new(0.0, 1.0, 0.0);
|
||||
let out_of_fov = false;
|
||||
let catalog_loaded = false;
|
||||
@@ -244,7 +244,7 @@ impl App {
|
||||
catalog_loaded,
|
||||
|
||||
tile_fetcher,
|
||||
|
||||
north_up: false,
|
||||
colormaps,
|
||||
projection,
|
||||
|
||||
@@ -421,17 +421,17 @@ impl App {
|
||||
|
||||
let v = cell.vertices();
|
||||
let proj2screen = |(lon, lat): &(f64, f64)| -> Option<[f64; 2]> {
|
||||
// 1. convert to xyzw
|
||||
let xyzw = crate::math::lonlat::radec_to_xyzw(lon.to_angle(), lat.to_angle());
|
||||
// 1. convert to xyz
|
||||
let xyz = crate::math::lonlat::radec_to_xyz(lon.to_angle(), lat.to_angle());
|
||||
// 2. get it back to the camera frame system
|
||||
let xyzw = crate::coosys::apply_coo_system(
|
||||
let xyz = crate::coosys::apply_coo_system(
|
||||
CooSystem::ICRS,
|
||||
self.camera.get_coo_system(),
|
||||
&xyzw,
|
||||
&xyz,
|
||||
);
|
||||
|
||||
// 3. project on screen
|
||||
if let Some(p) = self.projection.model_to_clip_space(&xyzw, &self.camera) {
|
||||
if let Some(p) = self.projection.model_to_clip_space(&xyz, &self.camera) {
|
||||
Some([p.x, p.y])
|
||||
} else {
|
||||
None
|
||||
@@ -1353,11 +1353,12 @@ impl App {
|
||||
pub(crate) fn resize(&mut self, width: f32, height: f32) {
|
||||
self.camera.set_screen_size(width, height, &self.projection);
|
||||
self.camera
|
||||
.set_aperture(self.camera.get_aperture(), &self.projection);
|
||||
.set_zoom_factor(self.camera.get_zoom_factor(), &self.projection);
|
||||
|
||||
// resize the view fbo
|
||||
let screen_size = self.camera.get_screen_size();
|
||||
self._fbo_view
|
||||
.resize(screen_size.x as usize, screen_size.y as usize);
|
||||
//let screen_size = self.camera.get_screen_size();
|
||||
//self._fbo_view
|
||||
// .resize(screen_size.x as usize, screen_size.y as usize);
|
||||
// resize the ui fbo
|
||||
//self.fbo_ui.resize(w as usize, h as usize);
|
||||
|
||||
@@ -1443,9 +1444,9 @@ impl App {
|
||||
}
|
||||
|
||||
pub(crate) fn view_to_icrs_coosys(&self, lonlat: &LonLatT<f64>) -> LonLatT<f64> {
|
||||
let celestial_pos: Vector4<_> = lonlat.vector();
|
||||
let celestial_pos = lonlat.vector();
|
||||
let view_system = self.camera.get_coo_system();
|
||||
let (ra, dec) = math::lonlat::xyzw_to_radec(&coosys::apply_coo_system(
|
||||
let (ra, dec) = math::lonlat::xyz_to_radec(&coosys::apply_coo_system(
|
||||
view_system,
|
||||
CooSystem::ICRS,
|
||||
&celestial_pos,
|
||||
@@ -1456,7 +1457,7 @@ impl App {
|
||||
|
||||
/// lonlat must be given in icrs frame
|
||||
pub(crate) fn set_center(&mut self, lonlat: &LonLatT<f64>) {
|
||||
self.prev_cam_position = self.camera.get_center().truncate();
|
||||
self.prev_cam_position = *self.camera.get_center();
|
||||
|
||||
self.camera.set_center(lonlat, &self.projection);
|
||||
self.request_for_new_tiles = true;
|
||||
@@ -1520,11 +1521,11 @@ impl App {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
let now = Time::now();
|
||||
let dragging_duration = (now - self.time_start_dragging).as_secs();
|
||||
let dragging_vel = self.dist_dragging / dragging_duration;
|
||||
|
||||
let _dist_dragging = self.dist_dragging;
|
||||
// Detect if there has been a recent acceleration
|
||||
// It is also possible that the dragging time is too short and if it is the case, trigger the inertia
|
||||
let recent_acceleration = (Time::now() - self.time_mouse_high_vel).as_secs() < 0.1
|
||||
@@ -1537,31 +1538,31 @@ impl App {
|
||||
// Start inertia here
|
||||
// Angular distance between the previous and current
|
||||
// center position
|
||||
let center = self.camera.get_center().truncate();
|
||||
let axis = self.prev_cam_position.cross(center).normalize();
|
||||
let center = self.camera.get_center();
|
||||
let axis = self.prev_cam_position.cross(*center).normalize();
|
||||
|
||||
//let delta_time = ((now - time_of_last_move).0 as f64).max(1.0);
|
||||
let delta_angle = math::vector::angle3(&self.prev_cam_position, ¢er).to_radians();
|
||||
let ampl = delta_angle * (dragging_vel as f64) * 5e-3;
|
||||
//let ampl = (dragging_vel * 0.01) as f64;
|
||||
|
||||
self.inertia = Some(Inertia::new(ampl.to_radians(), axis))
|
||||
self.inertia = Some(Inertia::new(ampl.to_radians(), axis, self.north_up))
|
||||
}
|
||||
|
||||
pub(crate) fn set_view_center_pos_angle(&mut self, theta: ArcDeg<f64>) {
|
||||
pub(crate) fn set_position_angle(&mut self, theta: ArcDeg<f64>) {
|
||||
self.camera
|
||||
.set_center_pos_angle(theta.into(), &self.projection);
|
||||
.set_position_angle(theta.into(), &self.projection);
|
||||
// New tiles can be needed and some tiles can be removed
|
||||
self.request_for_new_tiles = true;
|
||||
|
||||
self.request_redraw = true;
|
||||
}
|
||||
|
||||
pub(crate) fn get_north_shift_angle(&self) -> Angle<f64> {
|
||||
self.camera.get_center_pos_angle()
|
||||
pub(crate) fn get_position_angle(&self) -> Angle<f64> {
|
||||
self.camera.get_position_angle()
|
||||
}
|
||||
|
||||
pub(crate) fn set_fov(&mut self, fov: Angle<f64>) {
|
||||
pub(crate) fn set_fov(&mut self, fov: f64) {
|
||||
// For the moment, no animation is triggered.
|
||||
// The fov is directly set
|
||||
self.camera.set_aperture(fov, &self.projection);
|
||||
@@ -1569,17 +1570,20 @@ impl App {
|
||||
self.request_redraw = true;
|
||||
}
|
||||
|
||||
pub(crate) fn set_fov_range(&mut self, min_fov: Option<f64>, max_fov: Option<f64>) {
|
||||
self.camera.set_fov_range(
|
||||
min_fov.map(|v| v.to_radians()),
|
||||
max_fov.map(|v| v.to_radians()),
|
||||
&self.projection,
|
||||
);
|
||||
self.request_for_new_tiles = true;
|
||||
self.request_redraw = true;
|
||||
}
|
||||
|
||||
pub(crate) fn set_inertia(&mut self, inertia: bool) {
|
||||
*self.disable_inertia.borrow_mut() = !inertia;
|
||||
}
|
||||
|
||||
/*pub(crate) fn project_line(&self, lon1: f64, lat1: f64, lon2: f64, lat2: f64) -> Vec<Vector2<f64>> {
|
||||
let v1: Vector3<f64> = LonLatT::new(ArcDeg(lon1).into(), ArcDeg(lat1).into()).vector();
|
||||
let v2: Vector3<f64> = LonLatT::new(ArcDeg(lon2).into(), ArcDeg(lat2).into()).vector();
|
||||
|
||||
line::project_along_great_circles(&v1, &v2, &self.camera, self.projection)
|
||||
}*/
|
||||
|
||||
pub(crate) fn go_from_to(&mut self, s1x: f64, s1y: f64, s2x: f64, s2y: f64) {
|
||||
// Select the HiPS layer rendered lastly
|
||||
if let (Some(w1), Some(w2)) = (
|
||||
@@ -1588,22 +1592,65 @@ impl App {
|
||||
self.projection
|
||||
.screen_to_model_space(&Vector2::new(s2x, s2y), &self.camera),
|
||||
) {
|
||||
let prev_pos = w1.truncate();
|
||||
//let cur_pos = w1.truncate();
|
||||
let cur_pos = w2.truncate();
|
||||
//let next_pos = w2.truncate();
|
||||
let prev_pos = w1;
|
||||
let cur_pos = w2;
|
||||
if prev_pos != cur_pos {
|
||||
/* 1. Rotate by computing the angle between the last and current position */
|
||||
let prev_cam_position = self.camera.get_center().clone();
|
||||
|
||||
// Apply the rotation to the camera to
|
||||
// go from the current pos to the next position
|
||||
let axis = prev_pos.cross(cur_pos).normalize();
|
||||
if self.north_up {
|
||||
let lonlat1 = prev_pos.lonlat();
|
||||
let lonlat2 = cur_pos.lonlat();
|
||||
|
||||
let d = math::vector::angle3(&prev_pos, &cur_pos);
|
||||
let dlon = lonlat2.lon() - lonlat1.lon();
|
||||
let dlat = lonlat2.lat() - lonlat1.lat();
|
||||
|
||||
self.camera.apply_lonlat_rotation(dlon, dlat, &self.projection);
|
||||
|
||||
self.prev_cam_position = self.camera.get_center().truncate();
|
||||
self.camera.apply_rotation(&(-axis), d, &self.projection);
|
||||
// Detect if a pole has been crossed
|
||||
|
||||
let north_pole = Vector3::new(0.0, 1.0, 0.0);
|
||||
let south_pole = Vector3::new(0.0, -1.0, 0.0);
|
||||
let cross_north_pole = crate::math::lonlat::is_in(&prev_cam_position, &self.camera.get_center(), &north_pole);
|
||||
let cross_south_pole = crate::math::lonlat::is_in(&prev_cam_position, &self.camera.get_center(), &south_pole);
|
||||
|
||||
let cross_pole = cross_north_pole | cross_south_pole;
|
||||
|
||||
// Detect if a pole has been crossed
|
||||
let center = if cross_pole {
|
||||
&prev_cam_position
|
||||
} else {
|
||||
self.camera.get_center()
|
||||
};
|
||||
|
||||
let fov = self.camera.get_aperture();
|
||||
|
||||
let pole = if center.y >= 0.0 {
|
||||
north_pole
|
||||
} else {
|
||||
south_pole
|
||||
};
|
||||
|
||||
let c2p = crate::math::vector::angle3(center, &pole).to_radians();
|
||||
let near_pole = c2p.abs() < 5e-3 * fov;
|
||||
if near_pole || cross_pole {
|
||||
// too near to the pole
|
||||
let axis = center.cross(pole).normalize();
|
||||
use crate::math::rotation::Rotation;
|
||||
let new_center = Rotation::from_axis_angle(&axis, (-5e-3 * fov).to_angle()).rotate(&pole);
|
||||
|
||||
self.camera.set_center_xyz(&new_center, &self.projection);
|
||||
self.camera.set_position_angle(0.0.to_angle(), &self.projection);
|
||||
}
|
||||
} else {
|
||||
/* 1. Rotate by computing the angle between the last and current position */
|
||||
|
||||
let d = math::vector::angle3(&prev_pos, &cur_pos);
|
||||
let axis = prev_pos.cross(cur_pos).normalize();
|
||||
|
||||
self.camera.apply_axis_rotation(&(-axis), d, &self.projection);
|
||||
}
|
||||
|
||||
self.prev_cam_position = prev_cam_position;
|
||||
self.request_for_new_tiles = true;
|
||||
}
|
||||
} else {
|
||||
@@ -1611,6 +1658,10 @@ impl App {
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn lock_north_up(&mut self) {
|
||||
self.north_up = true;
|
||||
}
|
||||
|
||||
pub(crate) fn add_cmap(&mut self, label: String, cmap: Colormap) -> Result<(), JsValue> {
|
||||
self.colormaps.add_cmap(label, cmap)
|
||||
}
|
||||
@@ -1624,13 +1675,19 @@ impl App {
|
||||
self.camera.get_texture_depth() as i32
|
||||
}
|
||||
|
||||
pub(crate) fn get_clip_zoom_factor(&self) -> f64 {
|
||||
self.camera.get_clip_zoom_factor()
|
||||
pub(crate) fn get_zoom_factor(&self) -> f64 {
|
||||
self.camera.get_zoom_factor()
|
||||
}
|
||||
|
||||
pub(crate) fn set_zoom_factor(&mut self, zoom_factor: f64) {
|
||||
self.camera.set_zoom_factor(zoom_factor, &self.projection);
|
||||
|
||||
self.request_for_new_tiles = true;
|
||||
self.request_redraw = true;
|
||||
}
|
||||
|
||||
pub(crate) fn get_fov(&self) -> f64 {
|
||||
let deg: ArcDeg<f64> = self.camera.get_aperture().into();
|
||||
deg.0
|
||||
self.camera.get_aperture().to_degrees()
|
||||
}
|
||||
|
||||
pub(crate) fn get_colormaps(&self) -> &Colormaps {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use cgmath::{Matrix4, Vector2};
|
||||
use cgmath::{Matrix3, Vector2};
|
||||
|
||||
use crate::math::projection::coo_space::{XYZWModel, XYZWWorld, XYNDC};
|
||||
use crate::math::projection::coo_space::{XYZModel, XYZWorld, XYNDC};
|
||||
|
||||
use crate::math::sph_geom::region::{Intersection, PoleContained, Region};
|
||||
use crate::math::{projection::Projection, sph_geom::bbox::BoundingBox};
|
||||
@@ -14,7 +14,7 @@ fn ndc_to_world(
|
||||
ndc_to_clip: &Vector2<f64>,
|
||||
clip_zoom_factor: f64,
|
||||
projection: &ProjectionType,
|
||||
) -> Option<Vec<XYZWWorld<f64>>> {
|
||||
) -> Option<Vec<XYZWorld<f64>>> {
|
||||
// Deproject the FOV from ndc to the world space
|
||||
let mut world_coo = Vec::with_capacity(ndc_coo.len());
|
||||
|
||||
@@ -34,7 +34,7 @@ fn ndc_to_world(
|
||||
|
||||
Some(world_coo)
|
||||
}
|
||||
fn world_to_model(world_coo: &[XYZWWorld<f64>], w2m: &Matrix4<f64>) -> Vec<XYZWModel<f64>> {
|
||||
fn world_to_model(world_coo: &[XYZWorld<f64>], w2m: &Matrix3<f64>) -> Vec<XYZModel<f64>> {
|
||||
let mut model_coo = Vec::with_capacity(world_coo.len());
|
||||
|
||||
for w in world_coo.iter() {
|
||||
@@ -61,8 +61,8 @@ const NUM_VERTICES: usize = 4 + 2 * NUM_VERTICES_WIDTH + 2 * NUM_VERTICES_HEIGHT
|
||||
pub struct FieldOfView {
|
||||
// Vertices
|
||||
ndc_vertices: Vec<XYNDC<f64>>,
|
||||
world_vertices: Option<Vec<XYZWWorld<f64>>>,
|
||||
model_vertices: Option<Vec<XYZWModel<f64>>>,
|
||||
world_vertices: Option<Vec<XYZWorld<f64>>>,
|
||||
model_vertices: Option<Vec<XYZModel<f64>>>,
|
||||
|
||||
reg: Region,
|
||||
}
|
||||
@@ -73,7 +73,7 @@ impl FieldOfView {
|
||||
ndc_to_clip: &Vector2<f64>,
|
||||
clip_zoom_factor: f64,
|
||||
// rotation
|
||||
rotation_mat: &Matrix4<f64>,
|
||||
rotation_mat: &Matrix3<f64>,
|
||||
// projection
|
||||
projection: &ProjectionType,
|
||||
) -> Self {
|
||||
@@ -123,7 +123,7 @@ impl FieldOfView {
|
||||
&mut self,
|
||||
ndc_to_clip: &Vector2<f64>,
|
||||
clip_zoom_factor: f64,
|
||||
rotate_mat: &Matrix4<f64>,
|
||||
rotate_mat: &Matrix3<f64>,
|
||||
projection: &ProjectionType,
|
||||
) {
|
||||
self.world_vertices = ndc_to_world(
|
||||
@@ -135,7 +135,7 @@ impl FieldOfView {
|
||||
self.set_rotation(rotate_mat);
|
||||
}
|
||||
|
||||
pub fn set_rotation(&mut self, rotate_mat: &Matrix4<f64>) {
|
||||
pub fn set_rotation(&mut self, rotate_mat: &Matrix3<f64>) {
|
||||
if let Some(world_vertices) = &self.world_vertices {
|
||||
self.model_vertices = Some(world_to_model(world_vertices, rotate_mat));
|
||||
} else {
|
||||
@@ -186,7 +186,7 @@ impl FieldOfView {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_vertices(&self) -> Option<&Vec<XYZWModel<f64>>> {
|
||||
pub fn get_vertices(&self) -> Option<&Vec<XYZModel<f64>>> {
|
||||
self.model_vertices.as_ref()
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
pub mod viewport;
|
||||
use crate::math::lonlat::LonLat;
|
||||
use crate::math::projection::coo_space::XYZWModel;
|
||||
use crate::math::projection::coo_space::XYZModel;
|
||||
pub use viewport::CameraViewPort;
|
||||
|
||||
pub mod fov;
|
||||
@@ -14,7 +14,7 @@ use crate::ProjectionType;
|
||||
pub fn build_fov_coverage(
|
||||
depth: u8,
|
||||
fov: &FieldOfView,
|
||||
camera_center: &XYZWModel<f64>,
|
||||
camera_center: &XYZModel<f64>,
|
||||
camera_frame: CooSystem,
|
||||
frame: CooSystem,
|
||||
proj: &ProjectionType,
|
||||
@@ -40,7 +40,7 @@ pub fn build_fov_coverage(
|
||||
// See https://github.com/cds-astro/cds-moc-rust/issues/3
|
||||
|
||||
let hpx_idxs_iter = vertices_iter.map(|v| {
|
||||
let (lon, lat) = crate::math::lonlat::xyzw_to_radec(&v);
|
||||
let (lon, lat) = crate::math::lonlat::xyz_to_radec(&v);
|
||||
::healpix::nested::hash(depth, lon.to_radians(), lat.to_radians())
|
||||
});
|
||||
|
||||
@@ -55,10 +55,10 @@ pub fn build_fov_coverage(
|
||||
moc
|
||||
}
|
||||
} else {
|
||||
let center_xyzw = crate::coosys::apply_coo_system(camera_frame, frame, camera_center);
|
||||
let center_xyz = crate::coosys::apply_coo_system(camera_frame, frame, camera_center);
|
||||
|
||||
let biggest_fov_rad = proj.aperture_start().to_radians();
|
||||
let lonlat = center_xyzw.lonlat();
|
||||
let lonlat = center_xyz.lonlat();
|
||||
HEALPixCoverage::from_cone(&lonlat, biggest_fov_rad * 0.5, depth)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use crate::camera::XYZWModel;
|
||||
use crate::camera::XYZModel;
|
||||
use crate::healpix::cell::HEALPixCell;
|
||||
|
||||
use crate::math::projection::*;
|
||||
@@ -30,7 +30,7 @@ impl ViewHpxCells {
|
||||
&mut self,
|
||||
camera_depth: u8,
|
||||
fov: &FieldOfView,
|
||||
center: &XYZWModel<f64>,
|
||||
center: &XYZModel<f64>,
|
||||
camera_frame: CooSystem,
|
||||
proj: &ProjectionType,
|
||||
// survey frame
|
||||
@@ -48,7 +48,7 @@ impl ViewHpxCells {
|
||||
&mut self,
|
||||
camera_depth: u8,
|
||||
fov: &FieldOfView,
|
||||
center: &XYZWModel<f64>,
|
||||
center: &XYZModel<f64>,
|
||||
camera_frame: CooSystem,
|
||||
proj: &ProjectionType,
|
||||
// survey frame
|
||||
@@ -68,7 +68,7 @@ impl ViewHpxCells {
|
||||
&mut self,
|
||||
camera_depth: u8,
|
||||
fov: &FieldOfView,
|
||||
center: &XYZWModel<f64>,
|
||||
center: &XYZModel<f64>,
|
||||
camera_frame: CooSystem,
|
||||
proj: &ProjectionType,
|
||||
) {
|
||||
@@ -149,7 +149,7 @@ impl HpxCells {
|
||||
&mut self,
|
||||
camera_depth: u8,
|
||||
fov: &FieldOfView,
|
||||
center: &XYZWModel<f64>,
|
||||
center: &XYZModel<f64>,
|
||||
camera_frame: CooSystem,
|
||||
proj: &ProjectionType,
|
||||
) {
|
||||
|
||||
@@ -8,26 +8,32 @@ pub enum UserAction {
|
||||
|
||||
use web_sys::WebGl2RenderingContext;
|
||||
// Longitude reversed identity matrix
|
||||
const ID_R: &Matrix4<f64> = &Matrix4::new(
|
||||
-1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0,
|
||||
const ID_R: &Matrix3<f64> = &Matrix3::new(
|
||||
-1.0, 0.0, 0.0,
|
||||
0.0, 1.0, 0.0,
|
||||
0.0, 0.0, 1.0,
|
||||
);
|
||||
|
||||
use cgmath::{Vector3, InnerSpace};
|
||||
use super::{fov::FieldOfView, view_hpx_cells::ViewHpxCells};
|
||||
use crate::healpix::cell::HEALPixCell;
|
||||
use crate::healpix::coverage::HEALPixCoverage;
|
||||
use crate::math::angle::ToAngle;
|
||||
use crate::math::{projection::coo_space::XYZWModel, projection::domain::sdf::ProjDef};
|
||||
use crate::math::{projection::coo_space::XYZModel, projection::domain::sdf::ProjDef};
|
||||
|
||||
use cgmath::{Matrix3, Vector2};
|
||||
const APERTURE_LOWER_LIMIT_RAD: f64 = (1.0_f64 / 36000.0).to_radians();
|
||||
const ZOOM_FACTOR_UPPER_LIMIT: f64 = 2.0;
|
||||
|
||||
use cgmath::{Matrix4, Vector2};
|
||||
pub struct CameraViewPort {
|
||||
// The field of view angle
|
||||
aperture: Angle<f64>,
|
||||
aperture: f64,
|
||||
// The rotation of the camera
|
||||
center: Vector4<f64>,
|
||||
center: Vector3<f64>,
|
||||
w2m_rot: Rotation<f64>,
|
||||
|
||||
w2m: Matrix4<f64>,
|
||||
m2w: Matrix4<f64>,
|
||||
w2m: Matrix3<f64>,
|
||||
m2w: Matrix3<f64>,
|
||||
// The width over height ratio
|
||||
aspect: f32,
|
||||
// The width of the screen in pixels
|
||||
@@ -44,7 +50,7 @@ pub struct CameraViewPort {
|
||||
|
||||
// Internal variable used for projection purposes
|
||||
ndc_to_clip: Vector2<f64>,
|
||||
clip_zoom_factor: f64,
|
||||
zoom_factor: f64,
|
||||
// The vertices in model space of the camera
|
||||
// This is useful for computing views according
|
||||
// to different image surveys
|
||||
@@ -71,6 +77,11 @@ pub struct CameraViewPort {
|
||||
gl: WebGlContext,
|
||||
coo_sys: CooSystem,
|
||||
reversed_longitude: bool,
|
||||
|
||||
// min field of view, by default 0.1 arcsec
|
||||
pub(crate) min_fov: Option<f64>,
|
||||
// an optional max field of view
|
||||
pub(crate) max_fov: Option<f64>,
|
||||
}
|
||||
use al_api::coo_system::CooSystem;
|
||||
use al_core::WebGlContext;
|
||||
@@ -81,7 +92,7 @@ use crate::{
|
||||
};
|
||||
|
||||
use crate::LonLatT;
|
||||
use cgmath::{SquareMatrix, Vector4};
|
||||
use cgmath::SquareMatrix;
|
||||
use wasm_bindgen::JsCast;
|
||||
|
||||
const MAX_DPI_LIMIT: f32 = 2.0;
|
||||
@@ -96,11 +107,11 @@ impl CameraViewPort {
|
||||
) -> CameraViewPort {
|
||||
let last_user_action = UserAction::Starting;
|
||||
|
||||
let aperture = projection.aperture_start();
|
||||
let aperture = projection.aperture_start().to_radians();
|
||||
|
||||
let w2m = Matrix4::identity();
|
||||
let w2m = Matrix3::identity();
|
||||
let m2w = w2m;
|
||||
let center = Vector4::new(0.0, 0.0, 0.0, 1.0);
|
||||
let center = Vector3::new(0.0, 0.0, 0.0);
|
||||
let moved = false;
|
||||
let zoomed = false;
|
||||
|
||||
@@ -122,9 +133,9 @@ impl CameraViewPort {
|
||||
|
||||
let aspect = height / width;
|
||||
let ndc_to_clip = Vector2::new(1.0, (height as f64) / (width as f64));
|
||||
let clip_zoom_factor = 1.0;
|
||||
let zoom_factor = 1.0;
|
||||
|
||||
let fov = FieldOfView::new(&ndc_to_clip, clip_zoom_factor, &w2m, projection);
|
||||
let fov = FieldOfView::new(&ndc_to_clip, zoom_factor, &w2m, projection);
|
||||
let gl = gl.clone();
|
||||
|
||||
let is_allsky = true;
|
||||
@@ -154,7 +165,7 @@ impl CameraViewPort {
|
||||
|
||||
// Internal variable used for projection purposes
|
||||
ndc_to_clip,
|
||||
clip_zoom_factor,
|
||||
zoom_factor,
|
||||
// The field of view
|
||||
fov,
|
||||
view_hpx_cells,
|
||||
@@ -177,6 +188,9 @@ impl CameraViewPort {
|
||||
coo_sys,
|
||||
// a flag telling if the viewport has a reversed longitude axis
|
||||
reversed_longitude,
|
||||
|
||||
min_fov: None,
|
||||
max_fov: None,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -223,13 +237,13 @@ impl CameraViewPort {
|
||||
|
||||
// check the projection
|
||||
match proj {
|
||||
ProjectionType::Tan(_) => self.aperture >= 100.0_f64.to_radians().to_angle(),
|
||||
ProjectionType::Mer(_) => self.aperture >= 120.0_f64.to_radians().to_angle(),
|
||||
ProjectionType::Stg(_) => self.aperture >= 200.0_f64.to_radians().to_angle(),
|
||||
ProjectionType::Tan(_) => self.aperture >= 100.0_f64.to_radians(),
|
||||
ProjectionType::Mer(_) => self.aperture >= 120.0_f64.to_radians(),
|
||||
ProjectionType::Stg(_) => self.aperture >= 200.0_f64.to_radians(),
|
||||
ProjectionType::Sin(_) => false,
|
||||
ProjectionType::Ait(_) => self.aperture >= 100.0_f64.to_radians().to_angle(),
|
||||
ProjectionType::Mol(_) => self.aperture >= 100.0_f64.to_radians().to_angle(),
|
||||
ProjectionType::Zea(_) => self.aperture >= 140.0_f64.to_radians().to_angle(),
|
||||
ProjectionType::Ait(_) => self.aperture >= 100.0_f64.to_radians(),
|
||||
ProjectionType::Mol(_) => self.aperture >= 100.0_f64.to_radians(),
|
||||
ProjectionType::Zea(_) => self.aperture >= 140.0_f64.to_radians(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -278,12 +292,8 @@ impl CameraViewPort {
|
||||
// Compute the new clip zoom factor
|
||||
self.compute_ndc_to_clip_factor(projection);
|
||||
|
||||
self.fov.set_aperture(
|
||||
&self.ndc_to_clip,
|
||||
self.clip_zoom_factor,
|
||||
&self.w2m,
|
||||
projection,
|
||||
);
|
||||
self.fov
|
||||
.set_aperture(&self.ndc_to_clip, self.zoom_factor, &self.w2m, projection);
|
||||
|
||||
let proj_area = projection.get_area();
|
||||
self.is_allsky = !proj_area.is_in(&math::projection::ndc_to_clip_space(
|
||||
@@ -325,7 +335,74 @@ impl CameraViewPort {
|
||||
self.set_aperture(self.aperture, proj);
|
||||
}
|
||||
|
||||
pub fn set_aperture(&mut self, aperture: Angle<f64>, proj: &ProjectionType) {
|
||||
/// Give a FoV range in radians
|
||||
pub(crate) fn set_fov_range(
|
||||
&mut self,
|
||||
mut min_fov: Option<f64>,
|
||||
mut max_fov: Option<f64>,
|
||||
proj: &ProjectionType,
|
||||
) {
|
||||
// Invert the min and max bounds if min > max
|
||||
if let (Some(min_fov), Some(max_fov)) = (min_fov.as_mut(), max_fov.as_mut()) {
|
||||
if *max_fov < *min_fov {
|
||||
std::mem::swap(max_fov, min_fov);
|
||||
}
|
||||
}
|
||||
|
||||
self.min_fov = min_fov;
|
||||
self.max_fov = max_fov;
|
||||
|
||||
self.set_aperture(self.aperture, proj);
|
||||
}
|
||||
|
||||
pub(crate) fn at_zoom_boundaries(&self, proj: &ProjectionType) -> bool {
|
||||
// The zoom factor cannot exceed an upper limit
|
||||
if self.zoom_factor >= ZOOM_FACTOR_UPPER_LIMIT {
|
||||
return true;
|
||||
}
|
||||
|
||||
// The field of view cannot go deeper a lower limit
|
||||
if self.aperture <= APERTURE_LOWER_LIMIT_RAD {
|
||||
return true;
|
||||
}
|
||||
|
||||
// The field of view might be forced in a user defined range
|
||||
if let Some(min_fov) = self.min_fov {
|
||||
if self.aperture <= min_fov {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if let Some(max_fov) = self.max_fov {
|
||||
if self.aperture >= max_fov {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
let can_unzoom_more = match proj {
|
||||
ProjectionType::Tan(_) | ProjectionType::Mer(_) | ProjectionType::Stg(_) => false,
|
||||
_ => true,
|
||||
};
|
||||
|
||||
if !can_unzoom_more && self.zoom_factor >= 1.0 {
|
||||
return true;
|
||||
}
|
||||
|
||||
false
|
||||
}
|
||||
|
||||
pub(crate) fn set_aperture(&mut self, mut aperture: f64, proj: &ProjectionType) {
|
||||
// Force the given aperture by a range given by the user
|
||||
if let Some(min_fov) = self.min_fov {
|
||||
aperture = aperture.max(min_fov);
|
||||
}
|
||||
|
||||
if let Some(max_fov) = self.max_fov {
|
||||
aperture = aperture.min(max_fov);
|
||||
}
|
||||
|
||||
// Limit internally the aperture to 0.1 arcsec
|
||||
aperture = aperture.max(APERTURE_LOWER_LIMIT_RAD);
|
||||
|
||||
// Checking if we are zooming or unzooming
|
||||
// This is used internaly for the raytracer to compute
|
||||
// blending between tiles and their parents (or children)
|
||||
@@ -338,23 +415,15 @@ impl CameraViewPort {
|
||||
};
|
||||
|
||||
let can_unzoom_more = match proj {
|
||||
ProjectionType::Tan(_)
|
||||
| ProjectionType::Mer(_)
|
||||
//| ProjectionType::Air(_)
|
||||
| ProjectionType::Stg(_) => false,
|
||||
//| ProjectionType::Car(_)
|
||||
//| ProjectionType::Cea(_)
|
||||
//| ProjectionType::Cyp(_)
|
||||
//| ProjectionType::Hpx(_) => false,
|
||||
ProjectionType::Tan(_) | ProjectionType::Mer(_) | ProjectionType::Stg(_) => false,
|
||||
_ => true,
|
||||
};
|
||||
|
||||
let aperture_start = proj.aperture_start();
|
||||
let aperture_start: f64 = proj.aperture_start().to_radians();
|
||||
|
||||
self.clip_zoom_factor = if aperture > aperture_start {
|
||||
//al_core::log(&format!("a: {:?}, as: {:?}", aperture, aperture_start));
|
||||
self.zoom_factor = if aperture > aperture_start {
|
||||
if can_unzoom_more {
|
||||
aperture.to_radians() / aperture_start.to_radians()
|
||||
aperture / aperture_start
|
||||
} else {
|
||||
1.0
|
||||
}
|
||||
@@ -362,35 +431,24 @@ impl CameraViewPort {
|
||||
// Compute the new clip zoom factor
|
||||
let a = aperture.abs();
|
||||
|
||||
let v0 = math::lonlat::radec_to_xyzw(-a / 2.0, 0.0.to_angle());
|
||||
let v1 = math::lonlat::radec_to_xyzw(a / 2.0, 0.0.to_angle());
|
||||
let v0 = math::lonlat::radec_to_xyz(-a.to_angle() / 2.0, 0.0.to_angle());
|
||||
let v1 = math::lonlat::radec_to_xyz(a.to_angle() / 2.0, 0.0.to_angle());
|
||||
|
||||
// Vertex in the WCS of the FOV
|
||||
if self.width < self.height {
|
||||
if let (Some(p0), Some(p1)) =
|
||||
(proj.world_to_clip_space(&v0), proj.world_to_clip_space(&v1))
|
||||
{
|
||||
(0.5 * (p1.x - p0.x).abs()).min(1.0)
|
||||
} else {
|
||||
1.0
|
||||
}
|
||||
if let (Some(p0), Some(p1)) =
|
||||
(proj.world_to_clip_space(&v0), proj.world_to_clip_space(&v1))
|
||||
{
|
||||
(0.5 * (p1.x - p0.x).abs()).min(1.0)
|
||||
} else {
|
||||
if let (Some(p0), Some(p1)) =
|
||||
(proj.world_to_clip_space(&v0), proj.world_to_clip_space(&v1))
|
||||
{
|
||||
(0.5 * (p1.x - p0.x).abs()).min(1.0)
|
||||
} else {
|
||||
1.0
|
||||
}
|
||||
1.0
|
||||
}
|
||||
};
|
||||
|
||||
// Limit the zoom factor to not unzoom too much
|
||||
self.zoom_factor = self.zoom_factor.min(ZOOM_FACTOR_UPPER_LIMIT);
|
||||
|
||||
// Limit later the aperture to aperture_start
|
||||
self.aperture = aperture.min(aperture_start);
|
||||
//self.aperture = aperture;
|
||||
|
||||
//al_core::log(&format!("zoom factor {:?}", self.clip_zoom_factor));
|
||||
|
||||
//console_log(&format!("clip factor {:?}", self.aperture));
|
||||
|
||||
// Project this vertex into the screen
|
||||
self.moved = true;
|
||||
@@ -398,7 +456,101 @@ impl CameraViewPort {
|
||||
self.time_last_move = Time::now();
|
||||
|
||||
self.fov
|
||||
.set_aperture(&self.ndc_to_clip, self.clip_zoom_factor, &self.w2m, proj);
|
||||
.set_aperture(&self.ndc_to_clip, self.zoom_factor, &self.w2m, proj);
|
||||
|
||||
let proj_area = proj.get_area();
|
||||
self.is_allsky = !proj_area.is_in(&math::projection::ndc_to_clip_space(
|
||||
&Vector2::new(-1.0, -1.0),
|
||||
self,
|
||||
));
|
||||
|
||||
self.compute_texture_depth();
|
||||
|
||||
// Recompute the scissor with the new aperture
|
||||
self.recompute_scissor();
|
||||
|
||||
// Compute the hpx cells
|
||||
self.view_hpx_cells.update(
|
||||
self.texture_depth,
|
||||
&self.fov,
|
||||
&self.center,
|
||||
self.get_coo_system(),
|
||||
proj,
|
||||
);
|
||||
}
|
||||
|
||||
pub(crate) fn set_zoom_factor(&mut self, zoom_factor: f64, proj: &ProjectionType) {
|
||||
// Checking if we are zooming or unzooming
|
||||
// This is used internaly for the raytracer to compute
|
||||
// blending between tiles and their parents (or children)
|
||||
self.last_user_action = if self.zoom_factor > zoom_factor {
|
||||
UserAction::Zooming
|
||||
} else if self.zoom_factor < zoom_factor {
|
||||
UserAction::Unzooming
|
||||
} else {
|
||||
self.last_user_action
|
||||
};
|
||||
|
||||
let can_unzoom_more = match proj {
|
||||
ProjectionType::Tan(_) | ProjectionType::Mer(_) | ProjectionType::Stg(_) => false,
|
||||
_ => true,
|
||||
};
|
||||
|
||||
// Set the zoom factor
|
||||
self.zoom_factor = zoom_factor;
|
||||
// Limit it to prevent unzooming infinitely
|
||||
self.zoom_factor = self.zoom_factor.min(ZOOM_FACTOR_UPPER_LIMIT);
|
||||
|
||||
let aperture_start = proj.aperture_start().to_radians();
|
||||
|
||||
// clamp it to one if we cannot unzoom more (because of the projection)
|
||||
let aperture = if !can_unzoom_more && zoom_factor >= 1.0 {
|
||||
self.zoom_factor = 1.0;
|
||||
|
||||
aperture_start
|
||||
} else if can_unzoom_more && zoom_factor >= 1.0 {
|
||||
aperture_start
|
||||
} else {
|
||||
// zoom_factor < 1.0
|
||||
if let Some((lon, _)) = proj
|
||||
.clip_to_world_space(&Vector2::new(self.zoom_factor, 0.0))
|
||||
.map(|xyz| math::lonlat::xyz_to_radec(&xyz))
|
||||
{
|
||||
lon.to_radians().abs() * 2.0
|
||||
} else {
|
||||
aperture_start
|
||||
}
|
||||
};
|
||||
|
||||
// Force the given aperture to be in an optional range given by the user
|
||||
let mut clamped_aperture = aperture;
|
||||
if let Some(min_fov) = self.min_fov {
|
||||
clamped_aperture = clamped_aperture.max(min_fov);
|
||||
}
|
||||
|
||||
if let Some(max_fov) = self.max_fov {
|
||||
clamped_aperture = clamped_aperture.min(max_fov);
|
||||
}
|
||||
|
||||
// The aperture must also be > to a lower limit
|
||||
clamped_aperture = clamped_aperture.max(APERTURE_LOWER_LIMIT_RAD);
|
||||
|
||||
if clamped_aperture != aperture {
|
||||
// there has been a clamping of the aperture, then we recompute the zoom factor
|
||||
// with the new clamped aperture
|
||||
self.set_aperture(clamped_aperture, proj);
|
||||
return;
|
||||
}
|
||||
|
||||
self.aperture = aperture;
|
||||
|
||||
// Project this vertex into the screen
|
||||
self.moved = true;
|
||||
self.zoomed = true;
|
||||
self.time_last_move = Time::now();
|
||||
|
||||
self.fov
|
||||
.set_aperture(&self.ndc_to_clip, self.zoom_factor, &self.w2m, proj);
|
||||
|
||||
let proj_area = proj.get_area();
|
||||
self.is_allsky = !proj_area.is_in(&math::projection::ndc_to_clip_space(
|
||||
@@ -448,8 +600,7 @@ impl CameraViewPort {
|
||||
let smallest_cell_size_px = self.dpi as f64;
|
||||
let mut depth_pixel = 29 as usize;
|
||||
|
||||
let hpx_cell_size_rad =
|
||||
(smallest_cell_size_px / w_screen_px) * self.get_aperture().to_radians();
|
||||
let hpx_cell_size_rad = (smallest_cell_size_px / w_screen_px) * self.get_aperture();
|
||||
|
||||
while depth_pixel > 0 {
|
||||
if crate::healpix::utils::MEAN_HPX_CELL_RES[depth_pixel] > hpx_cell_size_rad {
|
||||
@@ -471,7 +622,7 @@ impl CameraViewPort {
|
||||
self.texture_depth
|
||||
}
|
||||
|
||||
pub fn apply_rotation(
|
||||
pub fn apply_axis_rotation(
|
||||
&mut self,
|
||||
axis: &cgmath::Vector3<f64>,
|
||||
angle: Angle<f64>,
|
||||
@@ -484,14 +635,29 @@ impl CameraViewPort {
|
||||
self.update_rot_matrices(proj);
|
||||
}
|
||||
|
||||
pub fn apply_lonlat_rotation(
|
||||
&mut self,
|
||||
dlon: Angle<f64>,
|
||||
dlat: Angle<f64>,
|
||||
proj: &ProjectionType
|
||||
) {
|
||||
let center = self.get_center();
|
||||
let rot = Rotation::from_axis_angle(&Vector3::new(center.z, 0.0, -center.x).normalize(), dlat) * Rotation::from_axis_angle(&Vector3::unit_y(), -dlon) * Rotation::from_sky_position(¢er);
|
||||
|
||||
self.set_rotation(&rot, proj);
|
||||
}
|
||||
|
||||
/// center lonlat must be given in icrs frame
|
||||
pub fn set_center(&mut self, lonlat: &LonLatT<f64>, proj: &ProjectionType) {
|
||||
let icrs_pos: Vector4<_> = lonlat.vector();
|
||||
let icrs_pos = lonlat.vector();
|
||||
self.set_center_xyz(&icrs_pos, proj);
|
||||
}
|
||||
|
||||
let center = (CooSystem::ICRS.to(self.get_coo_system()) * icrs_pos).truncate();
|
||||
pub fn set_center_xyz(&mut self, xyz: &Vector3<f64>, proj: &ProjectionType) {
|
||||
let center = CooSystem::ICRS.to(self.get_coo_system()) * xyz;
|
||||
let rot_to_center = Rotation::from_sky_position(¢er);
|
||||
|
||||
let phi = self.get_center_pos_angle();
|
||||
let phi = self.get_position_angle();
|
||||
let third_euler_rot = Rotation::from_axis_angle(¢er, phi);
|
||||
|
||||
let rot = third_euler_rot * rot_to_center;
|
||||
@@ -501,8 +667,8 @@ impl CameraViewPort {
|
||||
self.set_rotation(&rot, proj);
|
||||
}
|
||||
|
||||
pub fn set_center_pos_angle(&mut self, phi: Angle<f64>, proj: &ProjectionType) {
|
||||
let c = self.center.truncate();
|
||||
pub fn set_position_angle(&mut self, phi: Angle<f64>, proj: &ProjectionType) {
|
||||
let c = self.center;
|
||||
let rot_to_center = Rotation::from_sky_position(&c);
|
||||
let third_euler_rot = Rotation::from_axis_angle(&c, phi);
|
||||
|
||||
@@ -510,7 +676,7 @@ impl CameraViewPort {
|
||||
self.set_rotation(&total_rot, proj);
|
||||
}
|
||||
|
||||
fn set_rotation(&mut self, rot: &Rotation<f64>, proj: &ProjectionType) {
|
||||
pub fn set_rotation(&mut self, rot: &Rotation<f64>, proj: &ProjectionType) {
|
||||
self.w2m_rot = *rot;
|
||||
|
||||
self.update_rot_matrices(proj);
|
||||
@@ -524,7 +690,7 @@ impl CameraViewPort {
|
||||
// Compute the center position according to the new coordinate frame system
|
||||
let new_center = coosys::apply_coo_system(self.coo_sys, new_coo_sys, &self.center);
|
||||
// Create a rotation object from that position
|
||||
let new_rotation = Rotation::from_sky_position(&new_center.truncate());
|
||||
let new_rotation = Rotation::from_sky_position(&new_center);
|
||||
// Apply it to the center of the view
|
||||
self.set_rotation(&new_rotation, proj);
|
||||
|
||||
@@ -565,11 +731,11 @@ impl CameraViewPort {
|
||||
}
|
||||
|
||||
// Accessors
|
||||
pub fn get_w2m(&self) -> &cgmath::Matrix4<f64> {
|
||||
pub fn get_w2m(&self) -> &cgmath::Matrix3<f64> {
|
||||
&self.w2m
|
||||
}
|
||||
|
||||
pub fn get_m2w(&self) -> &cgmath::Matrix4<f64> {
|
||||
pub fn get_m2w(&self) -> &cgmath::Matrix3<f64> {
|
||||
&self.m2w
|
||||
}
|
||||
|
||||
@@ -581,11 +747,11 @@ impl CameraViewPort {
|
||||
&self.ndc_to_clip
|
||||
}
|
||||
|
||||
pub fn get_clip_zoom_factor(&self) -> f64 {
|
||||
self.clip_zoom_factor
|
||||
pub fn get_zoom_factor(&self) -> f64 {
|
||||
self.zoom_factor
|
||||
}
|
||||
|
||||
pub fn get_vertices(&self) -> Option<&Vec<XYZWModel<f64>>> {
|
||||
pub fn get_vertices(&self) -> Option<&Vec<XYZModel<f64>>> {
|
||||
self.fov.get_vertices()
|
||||
}
|
||||
|
||||
@@ -623,13 +789,14 @@ impl CameraViewPort {
|
||||
self.zoomed = false;
|
||||
}
|
||||
|
||||
/// Aperture is given in radians
|
||||
#[inline]
|
||||
pub fn get_aperture(&self) -> Angle<f64> {
|
||||
pub fn get_aperture(&self) -> f64 {
|
||||
self.aperture
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn get_center(&self) -> &Vector4<f64> {
|
||||
pub fn get_center(&self) -> &Vector3<f64> {
|
||||
&self.center
|
||||
}
|
||||
|
||||
@@ -646,7 +813,7 @@ impl CameraViewPort {
|
||||
self.coo_sys
|
||||
}
|
||||
|
||||
pub fn get_center_pos_angle(&self) -> Angle<f64> {
|
||||
pub fn get_position_angle(&self) -> Angle<f64> {
|
||||
(self.w2m.x.y).atan2(self.w2m.y.y).to_angle()
|
||||
}
|
||||
}
|
||||
@@ -688,7 +855,7 @@ impl SendUniforms for CameraViewPort {
|
||||
fn attach_uniforms<'a>(&self, shader: &'a ShaderBound<'a>) -> &'a ShaderBound<'a> {
|
||||
shader
|
||||
.attach_uniform("ndc_to_clip", &self.ndc_to_clip) // Send ndc to clip
|
||||
.attach_uniform("czf", &self.clip_zoom_factor); // Send clip zoom factor
|
||||
.attach_uniform("czf", &self.zoom_factor); // Send clip zoom factor
|
||||
|
||||
shader
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use cgmath::Vector4;
|
||||
use cgmath::Vector3;
|
||||
use al_api::coo_system::CooSystem;
|
||||
|
||||
/// This is conversion method returning a transformation
|
||||
@@ -6,7 +6,7 @@ use al_api::coo_system::CooSystem;
|
||||
/// ICRS.
|
||||
/// The core projections are always performed in ICRS
|
||||
#[inline]
|
||||
pub fn apply_coo_system(c1: CooSystem, c2: CooSystem, v: &Vector4<f64>) -> Vector4<f64> {
|
||||
pub fn apply_coo_system(c1: CooSystem, c2: CooSystem, v: &Vector3<f64>) -> Vector3<f64> {
|
||||
let c1_2_c2_mat = c1.to(c2);
|
||||
c1_2_c2_mat * (*v)
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ use crate::math::lonlat::LonLatT;
|
||||
use crate::math::PI;
|
||||
use crate::math::{self, lonlat::LonLat};
|
||||
|
||||
use cgmath::{Vector4};
|
||||
use cgmath::Vector3;
|
||||
use moclib::{
|
||||
moc::range::{CellSelection, RangeMOC},
|
||||
qty::Hpx,
|
||||
@@ -81,8 +81,8 @@ impl HEALPixCoverage {
|
||||
HEALPixCoverage(moc)
|
||||
}
|
||||
|
||||
pub fn contains_coo(&self, coo: &Vector4<f64>) -> bool {
|
||||
let (lon, lat) = math::lonlat::xyzw_to_radec(coo);
|
||||
pub fn contains_coo(&self, coo: &Vector3<f64>) -> bool {
|
||||
let (lon, lat) = math::lonlat::xyz_to_radec(coo);
|
||||
self.0.is_in(lon.to_radians(), lat.to_radians())
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@ use crate::camera::CameraViewPort;
|
||||
use crate::math::angle::ToAngle;
|
||||
use crate::math::projection::ProjectionType;
|
||||
use crate::time::{DeltaTime, Time};
|
||||
|
||||
/// State for inertia
|
||||
pub struct Inertia {
|
||||
// Initial angular distance
|
||||
@@ -14,15 +13,17 @@ pub struct Inertia {
|
||||
axis: Vector3<f64>,
|
||||
// The time when the inertia begins
|
||||
time_start: Time,
|
||||
north_up: bool,
|
||||
}
|
||||
|
||||
impl Inertia {
|
||||
pub fn new(ampl: f64, axis: Vector3<f64>) -> Self {
|
||||
pub fn new(ampl: f64, axis: Vector3<f64>, north_up: bool) -> Self {
|
||||
Inertia {
|
||||
time_start: Time::now(),
|
||||
ampl: ampl,
|
||||
ampl,
|
||||
speed: ampl,
|
||||
axis: axis,
|
||||
axis,
|
||||
north_up
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +36,7 @@ impl Inertia {
|
||||
// where:
|
||||
// * k is the stiffness of the ressort
|
||||
// * m is its mass
|
||||
let w0 = 10.0;
|
||||
let w0 = 7.0;
|
||||
// The angular distance goes from d0 to 0.0
|
||||
//self.speed = self.ampl * ((-w0 * t).exp());
|
||||
// The angular distance goes from d0 to 0.0
|
||||
@@ -43,7 +44,11 @@ impl Inertia {
|
||||
/*let alpha = 1_f32 + (0_f32 - 1_f32) * (10_f32 * t + 1_f32) * (-10_f32 * t).exp();
|
||||
let alpha = alpha * alpha;
|
||||
let fov = start_fov * (1_f32 - alpha) + goal_fov * alpha;*/
|
||||
camera.apply_rotation(&self.axis, self.speed.to_angle(), proj)
|
||||
camera.apply_axis_rotation(&self.axis, self.speed.to_angle(), proj);
|
||||
|
||||
if self.north_up {
|
||||
camera.set_position_angle(0.0.to_angle(), proj);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_start_ampl(&self) -> f64 {
|
||||
|
||||
@@ -130,7 +130,7 @@ use al_core::Colormap;
|
||||
use al_core::WebGlContext;
|
||||
|
||||
use app::App;
|
||||
use cgmath::{Vector2, Vector4};
|
||||
use cgmath::{Vector2, Vector3};
|
||||
|
||||
use crate::healpix::cell::HEALPixCell;
|
||||
use math::angle::ArcDeg;
|
||||
@@ -469,6 +469,12 @@ impl WebClient {
|
||||
Ok(fov)
|
||||
}
|
||||
|
||||
/// Get the max aperture of a projection (in degrees)
|
||||
#[wasm_bindgen(js_name = atZoomBoundaries)]
|
||||
pub fn get_max_aperture(&self) -> bool {
|
||||
self.app.camera.at_zoom_boundaries(&self.app.projection)
|
||||
}
|
||||
|
||||
/// Set the field of view
|
||||
///
|
||||
/// # Arguments
|
||||
@@ -476,13 +482,12 @@ impl WebClient {
|
||||
/// * `fov` - The field of view in degrees
|
||||
#[wasm_bindgen(js_name = setFieldOfView)]
|
||||
pub fn set_fov(&mut self, fov: f64) -> Result<(), JsValue> {
|
||||
let fov = ArcDeg(fov).into();
|
||||
|
||||
self.app.set_fov(fov);
|
||||
self.app.set_fov(fov.to_radians());
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Enable/Disable inertia effect after panning and releasing the mouse
|
||||
#[wasm_bindgen(js_name = setInertia)]
|
||||
pub fn set_inertia(&mut self, inertia: bool) -> Result<(), JsValue> {
|
||||
self.app.set_inertia(inertia);
|
||||
@@ -490,23 +495,57 @@ impl WebClient {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Set a range of FoVs that contrains the zooming in that range
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `min_fov` - The minimum field of view value in degrees
|
||||
/// * `max_fov` - The maximum field of view value in degrees
|
||||
#[wasm_bindgen(js_name = setFoVRange)]
|
||||
pub fn set_fov_range(
|
||||
&mut self,
|
||||
min_fov: Option<f64>,
|
||||
max_fov: Option<f64>,
|
||||
) -> Result<(), JsValue> {
|
||||
self.app.set_fov_range(min_fov, max_fov);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Get the FoV range in degrees
|
||||
#[wasm_bindgen(js_name = getFoVRange)]
|
||||
pub fn get_fov_range(&self) -> Box<[f64]> {
|
||||
Box::new([
|
||||
self.app
|
||||
.camera
|
||||
.min_fov
|
||||
.map(|v| v.to_degrees())
|
||||
.unwrap_or(-1.0),
|
||||
self.app
|
||||
.camera
|
||||
.max_fov
|
||||
.map(|v| v.to_degrees())
|
||||
.unwrap_or(-1.0),
|
||||
])
|
||||
}
|
||||
|
||||
/// Set the absolute orientation of the view
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `theta` - The rotation angle in degrees
|
||||
#[wasm_bindgen(js_name = setViewCenter2NorthPoleAngle)]
|
||||
pub fn set_view_center_pos_angle(&mut self, theta: f64) -> Result<(), JsValue> {
|
||||
#[wasm_bindgen(js_name = setRotation)]
|
||||
pub fn set_rotation(&mut self, theta: f64) -> Result<(), JsValue> {
|
||||
let theta = ArcDeg(theta);
|
||||
self.app.set_view_center_pos_angle(theta);
|
||||
self.app.set_position_angle(theta);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Get the absolute orientation angle of the view
|
||||
#[wasm_bindgen(js_name = getViewCenter2NorthPoleAngle)]
|
||||
pub fn get_north_shift_angle(&mut self) -> Result<f64, JsValue> {
|
||||
let phi = self.app.get_north_shift_angle();
|
||||
#[wasm_bindgen(js_name = getRotation)]
|
||||
pub fn get_rotation(&mut self) -> Result<f64, JsValue> {
|
||||
let phi = self.app.get_position_angle();
|
||||
Ok(phi.to_degrees())
|
||||
}
|
||||
|
||||
@@ -537,14 +576,20 @@ impl WebClient {
|
||||
self.app.get_max_fov().to_degrees()
|
||||
}
|
||||
|
||||
/// Get the clip zoom factor of the view
|
||||
/// Get the zoom factor of the view
|
||||
///
|
||||
/// This factor is deduced from the field of view angle.
|
||||
/// It is a constant which when multiplied to the screen coordinates
|
||||
/// gives the coordinates in clipping space.
|
||||
#[wasm_bindgen(js_name = getClipZoomFactor)]
|
||||
pub fn get_clip_zoom_factor(&self) -> Result<f64, JsValue> {
|
||||
Ok(self.app.get_clip_zoom_factor())
|
||||
#[wasm_bindgen(js_name = getZoomFactor)]
|
||||
pub fn get_zoom_factor(&self) -> Result<f64, JsValue> {
|
||||
Ok(self.app.get_zoom_factor())
|
||||
}
|
||||
|
||||
/// Set the zoom factor of the view
|
||||
#[wasm_bindgen(js_name = setZoomFactor)]
|
||||
pub fn set_zoom_factor(&mut self, zoom_factor: f64) -> Result<(), JsValue> {
|
||||
Ok(self.app.set_zoom_factor(zoom_factor))
|
||||
}
|
||||
|
||||
/// Set the center of the view in ICRS coosys
|
||||
@@ -565,6 +610,11 @@ impl WebClient {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[wasm_bindgen(js_name = lockNorthUp)]
|
||||
pub fn lock_north_up(&mut self) {
|
||||
self.app.lock_north_up();
|
||||
}
|
||||
|
||||
/// Get the center of the view
|
||||
///
|
||||
/// This returns a javascript array of size 2.
|
||||
@@ -1059,12 +1109,12 @@ impl WebClient {
|
||||
let vertex_it = ra_deg
|
||||
.iter()
|
||||
.zip(dec_deg.iter())
|
||||
.map(|(ra, dec)| -> Vector4<f64> {
|
||||
.map(|(ra, dec)| -> Vector3<f64> {
|
||||
let lonlat = LonLatT(ra.to_radians().to_angle(), dec.to_radians().to_angle());
|
||||
lonlat.vector()
|
||||
});
|
||||
|
||||
let v_in = &Vector4::new(1.0, 0.0, 0.0, 1.0);
|
||||
let v_in = &Vector3::new(1.0, 0.0, 0.0);
|
||||
|
||||
let mut moc = HEALPixCoverage::from_3d_coos(pixel_d as u8 - 1, vertex_it, &v_in);
|
||||
if moc.sky_fraction() > 0.5 {
|
||||
|
||||
@@ -145,15 +145,6 @@ where
|
||||
#[derive(Clone, Copy)]
|
||||
pub struct ArcSec<T: BaseFloat>(pub T);
|
||||
|
||||
impl<T> ArcSec<T>
|
||||
where
|
||||
T: BaseFloat,
|
||||
{
|
||||
fn _truncate(&mut self) {
|
||||
*self = Self((*self).trunc());
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> From<Rad<T>> for ArcSec<T>
|
||||
where
|
||||
T: BaseFloat,
|
||||
@@ -409,7 +400,7 @@ where
|
||||
S::max_value().to_angle()
|
||||
}
|
||||
|
||||
pub fn to_radians(&self) -> S {
|
||||
pub const fn to_radians(&self) -> S {
|
||||
self.rad
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use crate::math::TWICE_PI;
|
||||
use crate::Abort;
|
||||
use cgmath::{BaseFloat, Matrix3, Rad, Vector3, Vector4};
|
||||
use cgmath::{BaseFloat, Matrix3, Rad, Vector3};
|
||||
|
||||
pub trait LonLat<S: BaseFloat> {
|
||||
fn lon(&self) -> Angle<S>;
|
||||
@@ -116,43 +116,6 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<S> LonLat<S> for Vector4<S>
|
||||
where
|
||||
S: BaseFloat,
|
||||
{
|
||||
#[inline]
|
||||
fn lon(&self) -> Angle<S> {
|
||||
let rad = Rad(self.x.atan2(self.z));
|
||||
Angle::new(rad)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn lat(&self) -> Angle<S> {
|
||||
let rad = Rad(self.y.atan2((self.x * self.x + self.z * self.z).sqrt()));
|
||||
Angle::new(rad)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn lonlat(&self) -> LonLatT<S> {
|
||||
let lon = self.x.atan2(self.z);
|
||||
let lat = self.y.atan2((self.x * self.x + self.z * self.z).sqrt());
|
||||
|
||||
LonLatT::new(lon.to_angle(), lat.to_angle())
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn from_lonlat(lonlat: &LonLatT<S>) -> Self {
|
||||
let theta = lonlat.lon();
|
||||
let delta = lonlat.lat();
|
||||
Vector4::<S>::new(
|
||||
delta.cos() * theta.sin(),
|
||||
delta.sin(),
|
||||
delta.cos() * theta.cos(),
|
||||
S::one(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn ang_between_lonlat<S: BaseFloat>(lonlat1: LonLatT<S>, lonlat2: LonLatT<S>) -> Angle<S> {
|
||||
let abs_diff_lon = (lonlat1.lon() - lonlat2.lon()).abs();
|
||||
@@ -169,14 +132,6 @@ pub fn xyz_to_radec<S: BaseFloat>(v: &Vector3<S>) -> (Angle<S>, Angle<S>) {
|
||||
(lon, lat)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn xyzw_to_radec<S: BaseFloat>(v: &Vector4<S>) -> (Angle<S>, Angle<S>) {
|
||||
let lon = (v.x.atan2(v.z)).to_angle();
|
||||
let lat = (v.y.atan2((v.x * v.x + v.z * v.z).sqrt())).to_angle();
|
||||
|
||||
(lon, lat)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn radec_to_xyz<S: BaseFloat>(theta: Angle<S>, delta: Angle<S>) -> Vector3<S> {
|
||||
let (ds, dc) = delta.to_radians().sin_cos();
|
||||
@@ -185,13 +140,6 @@ pub fn radec_to_xyz<S: BaseFloat>(theta: Angle<S>, delta: Angle<S>) -> Vector3<S
|
||||
Vector3::<S>::new(dc * ts, ds, dc * tc)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn radec_to_xyzw<S: BaseFloat>(theta: Angle<S>, delta: Angle<S>) -> Vector4<S> {
|
||||
let xyz = radec_to_xyz(theta, delta);
|
||||
|
||||
Vector4::<S>::new(xyz.x, xyz.y, xyz.z, S::one())
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn radec_to_basis<S: BaseFloat>(theta: Angle<S>, delta: Angle<S>) -> Matrix3<S> {
|
||||
Matrix3::<S>::new(
|
||||
@@ -221,8 +169,8 @@ pub fn proj(
|
||||
projection: &ProjectionType,
|
||||
camera: &CameraViewPort,
|
||||
) -> Option<XYNDC<f64>> {
|
||||
let xyzw = lonlat.vector();
|
||||
projection.model_to_normalized_device_space(&xyzw, camera)
|
||||
let xyz = lonlat.vector();
|
||||
projection.model_to_normalized_device_space(&xyz, camera)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
@@ -242,8 +190,8 @@ pub fn proj_to_screen(
|
||||
projection: &ProjectionType,
|
||||
camera: &CameraViewPort,
|
||||
) -> Option<XYScreen<f64>> {
|
||||
let xyzw = lonlat.vector();
|
||||
projection.model_to_screen_space(&xyzw, camera)
|
||||
let xyz = lonlat.vector();
|
||||
projection.model_to_screen_space(&xyz, camera)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
@@ -256,3 +204,10 @@ pub fn unproj_from_screen(
|
||||
.screen_to_model_space(&xy, camera)
|
||||
.map(|model_pos| model_pos.lonlat())
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_in(v1: &Vector3<f64>, v2: &Vector3<f64>, v: &Vector3<f64>) -> bool {
|
||||
let theta = crate::math::vector::angle3(&v1, &v2).abs();
|
||||
|
||||
crate::math::vector::angle3(&v1, &v).abs() < theta && crate::math::vector::angle3(&v, &v2).abs() < theta
|
||||
}
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
use cgmath::{Vector2, Vector3, Vector4};
|
||||
use cgmath::{Vector2, Vector3};
|
||||
|
||||
pub type XYScreen<S> = Vector2<S>;
|
||||
pub type XYNDC<S> = Vector2<S>;
|
||||
pub type XYClip<S> = Vector2<S>;
|
||||
pub type XYZWorld<S> = Vector3<S>;
|
||||
pub type XYZModel<S> = Vector3<S>;
|
||||
pub type XYZWWorld<S> = Vector4<S>;
|
||||
pub type XYZWModel<S> = Vector4<S>;
|
||||
|
||||
pub enum CooSpace {
|
||||
Screen,
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
use crate::camera::CameraViewPort;
|
||||
use crate::domain::sdf::ProjDefType;
|
||||
|
||||
use coo_space::XYZWModel;
|
||||
use coo_space::XYZModel;
|
||||
//use crate::num_traits::FloatConst;
|
||||
use crate::math::PI;
|
||||
|
||||
@@ -21,8 +21,8 @@ pub mod domain;
|
||||
|
||||
use crate::math::angle::ToAngle;
|
||||
|
||||
use domain::{basic, full::FullScreen};
|
||||
use crate::math::angle::Angle;
|
||||
use domain::{basic, full::FullScreen};
|
||||
/* S <-> NDC space conversion methods */
|
||||
pub fn screen_to_ndc_space(
|
||||
pos_screen_space: &XYScreen<f64>,
|
||||
@@ -61,7 +61,7 @@ pub fn ndc_to_screen_space(
|
||||
/* NDC <-> CLIP space conversion methods */
|
||||
pub fn clip_to_ndc_space(pos_clip_space: &XYClip<f64>, camera: &CameraViewPort) -> XYNDC<f64> {
|
||||
let ndc_to_clip = camera.get_ndc_to_clip();
|
||||
let clip_zoom_factor = camera.get_clip_zoom_factor();
|
||||
let clip_zoom_factor = camera.get_zoom_factor();
|
||||
|
||||
Vector2::new(
|
||||
pos_clip_space.x / (ndc_to_clip.x * clip_zoom_factor),
|
||||
@@ -74,7 +74,7 @@ pub fn ndc_to_clip_space(
|
||||
camera: &CameraViewPort,
|
||||
) -> XYClip<f64> {
|
||||
let ndc_to_clip = camera.get_ndc_to_clip();
|
||||
let clip_zoom_factor = camera.get_clip_zoom_factor();
|
||||
let clip_zoom_factor = camera.get_zoom_factor();
|
||||
|
||||
Vector2::new(
|
||||
pos_normalized_device.x * ndc_to_clip.x * clip_zoom_factor,
|
||||
@@ -101,7 +101,7 @@ pub fn screen_to_clip_space(
|
||||
|
||||
use al_api::coo_system::CooSystem;
|
||||
|
||||
use crate::coo_space::{XYClip, XYZWWorld};
|
||||
use crate::coo_space::{XYClip, XYZWorld};
|
||||
|
||||
pub enum ProjectionType {
|
||||
// Zenithal projections
|
||||
@@ -174,7 +174,7 @@ impl ProjectionType {
|
||||
&self,
|
||||
pos_screen_space: &XYScreen<f64>,
|
||||
camera: &CameraViewPort,
|
||||
) -> Option<XYZWWorld<f64>> {
|
||||
) -> Option<XYZWorld<f64>> {
|
||||
// Change the screen position according to the dpi
|
||||
//let dpi = camera.get_dpi();
|
||||
let pos_screen_space = *pos_screen_space;
|
||||
@@ -196,7 +196,7 @@ impl ProjectionType {
|
||||
&self,
|
||||
pos_screen_space: &XYScreen<f64>,
|
||||
camera: &CameraViewPort,
|
||||
) -> Option<XYZWModel<f64>> {
|
||||
) -> Option<XYZModel<f64>> {
|
||||
self.screen_to_world_space(pos_screen_space, camera)
|
||||
.map(|world_pos| camera.get_w2m() * world_pos)
|
||||
}
|
||||
@@ -205,14 +205,14 @@ impl ProjectionType {
|
||||
&self,
|
||||
ndc_pos: &XYNDC<f64>,
|
||||
camera: &CameraViewPort,
|
||||
) -> Option<XYZWModel<f64>> {
|
||||
) -> Option<XYZModel<f64>> {
|
||||
self.normalized_device_to_world_space(ndc_pos, camera)
|
||||
.map(|world_pos| camera.get_w2m() * world_pos)
|
||||
}
|
||||
|
||||
pub fn model_to_screen_space(
|
||||
&self,
|
||||
pos_model_space: &XYZWModel<f64>,
|
||||
pos_model_space: &XYZModel<f64>,
|
||||
camera: &CameraViewPort,
|
||||
) -> Option<XYScreen<f64>> {
|
||||
let m2w = camera.get_m2w();
|
||||
@@ -222,7 +222,7 @@ impl ProjectionType {
|
||||
|
||||
pub fn icrs_celestial_to_screen_space(
|
||||
&self,
|
||||
celestial_pos: &XYZWModel<f64>,
|
||||
celestial_pos: &XYZModel<f64>,
|
||||
camera: &CameraViewPort,
|
||||
) -> Option<XYScreen<f64>> {
|
||||
self.icrs_celestial_to_normalized_device_space(celestial_pos, camera)
|
||||
@@ -231,7 +231,7 @@ impl ProjectionType {
|
||||
|
||||
pub fn icrs_celestial_to_normalized_device_space(
|
||||
&self,
|
||||
celestial_pos: &XYZWModel<f64>,
|
||||
celestial_pos: &XYZModel<f64>,
|
||||
camera: &CameraViewPort,
|
||||
) -> Option<XYNDC<f64>> {
|
||||
let view_coosys = camera.get_coo_system();
|
||||
@@ -244,7 +244,7 @@ impl ProjectionType {
|
||||
|
||||
pub fn model_to_normalized_device_space(
|
||||
&self,
|
||||
pos_model_space: &XYZWModel<f64>,
|
||||
pos_model_space: &XYZModel<f64>,
|
||||
camera: &CameraViewPort,
|
||||
) -> Option<XYNDC<f64>> {
|
||||
let m2w = camera.get_m2w();
|
||||
@@ -254,7 +254,7 @@ impl ProjectionType {
|
||||
|
||||
pub fn model_to_clip_space(
|
||||
&self,
|
||||
pos_model_space: &XYZWModel<f64>,
|
||||
pos_model_space: &XYZModel<f64>,
|
||||
camera: &CameraViewPort,
|
||||
) -> Option<XYClip<f64>> {
|
||||
let m2w = camera.get_m2w();
|
||||
@@ -272,7 +272,7 @@ impl ProjectionType {
|
||||
/// * `y` - Y mouse position in homogenous screen space (between [-1, 1])
|
||||
pub fn world_to_normalized_device_space(
|
||||
&self,
|
||||
pos_world_space: &XYZWWorld<f64>,
|
||||
pos_world_space: &XYZWorld<f64>,
|
||||
camera: &CameraViewPort,
|
||||
) -> Option<XYNDC<f64>> {
|
||||
self.world_to_clip_space(pos_world_space)
|
||||
@@ -283,39 +283,30 @@ impl ProjectionType {
|
||||
&self,
|
||||
ndc_pos: &XYNDC<f64>,
|
||||
camera: &CameraViewPort,
|
||||
) -> Option<XYZWWorld<f64>> {
|
||||
) -> Option<XYZWorld<f64>> {
|
||||
let clip_pos = ndc_to_clip_space(ndc_pos, camera);
|
||||
self.clip_to_world_space(&clip_pos)
|
||||
}
|
||||
|
||||
pub fn world_to_screen_space(
|
||||
&self,
|
||||
pos_world_space: &XYZWWorld<f64>,
|
||||
pos_world_space: &XYZWorld<f64>,
|
||||
camera: &CameraViewPort,
|
||||
) -> Option<XYScreen<f64>> {
|
||||
self.world_to_normalized_device_space(pos_world_space, camera)
|
||||
.map(|pos_normalized_device| ndc_to_screen_space(&pos_normalized_device, camera))
|
||||
}
|
||||
|
||||
/*pub(crate) fn is_allsky(&self) -> bool {
|
||||
match self {
|
||||
ProjectionType::Sin(_) | ProjectionType::Tan(_) => false,
|
||||
//| ProjectionType::Feye(_)
|
||||
//| ProjectionType::Ncp(_) => false,
|
||||
_ => true,
|
||||
}
|
||||
}*/
|
||||
|
||||
pub const fn bounds_size_ratio(&self) -> f64 {
|
||||
match self {
|
||||
// Zenithal projections
|
||||
/* TAN, Gnomonic projection */
|
||||
ProjectionType::Tan(_) => 1.0,
|
||||
/* STG, Stereographic projection */
|
||||
/* STG, Stereographic projection */
|
||||
ProjectionType::Stg(_) => 1.0,
|
||||
/* SIN, Orthographic */
|
||||
/* SIN, Orthographic */
|
||||
ProjectionType::Sin(_) => 1.0,
|
||||
/* ZEA, Equal-area */
|
||||
/* ZEA, Equal-area */
|
||||
ProjectionType::Zea(_) => 1.0,
|
||||
/* FEYE, Fish-eyes */
|
||||
//ProjectionType::Feye(_) => 1.0,
|
||||
@@ -327,7 +318,6 @@ impl ProjectionType {
|
||||
//ProjectionType::Arc(_) => 1.0,
|
||||
/* NCP, */
|
||||
//ProjectionType::Ncp(_) => 1.0,
|
||||
|
||||
// Pseudo-cylindrical projections
|
||||
/* AIT, Aitoff */
|
||||
ProjectionType::Ait(_) => 2.0,
|
||||
@@ -337,7 +327,6 @@ impl ProjectionType {
|
||||
//ProjectionType::Par(_) => 2.0,
|
||||
// SFL, */
|
||||
//ProjectionType::Sfl(_) => 2.0,
|
||||
|
||||
// Cylindrical projections
|
||||
// MER, Mercator */
|
||||
ProjectionType::Mer(_) => 1.0,
|
||||
@@ -347,11 +336,9 @@ impl ProjectionType {
|
||||
//ProjectionType::Cea(_) => 1.0,
|
||||
// CYP, */
|
||||
//ProjectionType::Cyp(_) => 1.0,
|
||||
|
||||
// Conic projections
|
||||
// COD, */
|
||||
//ProjectionType::Cod(_) => 1.0,
|
||||
|
||||
// HEALPix hybrid projection
|
||||
//ProjectionType::Hpx(_) => 2.0,
|
||||
}
|
||||
@@ -367,7 +354,7 @@ impl ProjectionType {
|
||||
/* SIN, Orthographic */
|
||||
ProjectionType::Sin(_) => 180.0_f64.to_radians().to_angle(),
|
||||
/* ZEA, Equal-area */
|
||||
ProjectionType::Zea(_) => 360.0_f64.to_radians().to_angle(),
|
||||
ProjectionType::Zea(_) => 359.9_f64.to_radians().to_angle(),
|
||||
/* FEYE, Fish-eyes */
|
||||
//ProjectionType::Feye(_) => 190.0,
|
||||
/* AIR, */
|
||||
@@ -408,7 +395,7 @@ impl ProjectionType {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_area(&self) -> &ProjDefType {
|
||||
pub const fn get_area(&self) -> &ProjDefType {
|
||||
match self {
|
||||
// Zenithal projections
|
||||
/* TAN, Gnomonic projection */
|
||||
@@ -514,7 +501,7 @@ impl ProjectionType {
|
||||
|
||||
impl Projection for ProjectionType {
|
||||
/// Deprojection
|
||||
fn clip_to_world_space(&self, xy: &XYClip<f64>) -> Option<XYZWWorld<f64>> {
|
||||
fn clip_to_world_space(&self, xy: &XYClip<f64>) -> Option<XYZWorld<f64>> {
|
||||
match self {
|
||||
// Zenithal projections
|
||||
/* TAN, Gnomonic projection */
|
||||
@@ -558,11 +545,11 @@ impl Projection for ProjectionType {
|
||||
|
||||
// Conic projections
|
||||
// COD, */
|
||||
/*ProjectionType::Cod(cod) => cod.clip_to_world_space(xy).map(|xyzw| {
|
||||
/*ProjectionType::Cod(cod) => cod.clip_to_world_space(xy).map(|xyz| {
|
||||
let rot = Rotation::from_sky_position(
|
||||
&LonLatT::new(0.0_f64.to_angle(), (HALF_PI * 0.5).to_angle()).vector(),
|
||||
);
|
||||
rot.inv_rotate(&xyzw)
|
||||
rot.inv_rotate(&xyz)
|
||||
}),*/
|
||||
// HEALPix hybrid projection
|
||||
//ProjectionType::Hpx(hpx) => hpx.clip_to_world_space(xy),
|
||||
@@ -570,47 +557,47 @@ impl Projection for ProjectionType {
|
||||
}
|
||||
|
||||
// Projection
|
||||
fn world_to_clip_space(&self, xyzw: &XYZWWorld<f64>) -> Option<XYClip<f64>> {
|
||||
fn world_to_clip_space(&self, xyz: &XYZWorld<f64>) -> Option<XYClip<f64>> {
|
||||
match self {
|
||||
// Zenithal projections
|
||||
/* TAN, Gnomonic projection */
|
||||
ProjectionType::Tan(tan) => tan.world_to_clip_space(xyzw),
|
||||
ProjectionType::Tan(tan) => tan.world_to_clip_space(xyz),
|
||||
/* STG, Stereographic projection */
|
||||
ProjectionType::Stg(stg) => stg.world_to_clip_space(xyzw),
|
||||
ProjectionType::Stg(stg) => stg.world_to_clip_space(xyz),
|
||||
/* SIN, Orthographic */
|
||||
ProjectionType::Sin(sin) => sin.world_to_clip_space(xyzw),
|
||||
ProjectionType::Sin(sin) => sin.world_to_clip_space(xyz),
|
||||
/* ZEA, Equal-area */
|
||||
ProjectionType::Zea(zea) => zea.world_to_clip_space(xyzw),
|
||||
ProjectionType::Zea(zea) => zea.world_to_clip_space(xyz),
|
||||
/* FEYE, Fish-eyes */
|
||||
//ProjectionType::Feye(feye) => feye.world_to_clip_space(xyzw),
|
||||
//ProjectionType::Feye(feye) => feye.world_to_clip_space(xyz),
|
||||
/* AIR, */
|
||||
//ProjectionType::Air(air) => air.world_to_clip_space(xyzw),
|
||||
//ProjectionType::Air(air) => air.world_to_clip_space(xyz),
|
||||
//AZP: {fov: 180},
|
||||
//Azp(mapproj::zenithal::azp::Azp),
|
||||
/* ARC, */
|
||||
//ProjectionType::Arc(arc) => arc.world_to_clip_space(xyzw),
|
||||
//ProjectionType::Arc(arc) => arc.world_to_clip_space(xyz),
|
||||
/* NCP, */
|
||||
//ProjectionType::Ncp(ncp) => ncp.world_to_clip_space(xyzw),
|
||||
//ProjectionType::Ncp(ncp) => ncp.world_to_clip_space(xyz),
|
||||
|
||||
// Pseudo-cylindrical projections
|
||||
/* AIT, Aitoff */
|
||||
ProjectionType::Ait(ait) => ait.world_to_clip_space(xyzw),
|
||||
ProjectionType::Ait(ait) => ait.world_to_clip_space(xyz),
|
||||
// MOL, Mollweide */
|
||||
ProjectionType::Mol(mol) => mol.world_to_clip_space(xyzw),
|
||||
ProjectionType::Mol(mol) => mol.world_to_clip_space(xyz),
|
||||
// PAR, */
|
||||
//ProjectionType::Par(par) => par.world_to_clip_space(xyzw),
|
||||
//ProjectionType::Par(par) => par.world_to_clip_space(xyz),
|
||||
// SFL, */
|
||||
//ProjectionType::Sfl(sfl) => sfl.world_to_clip_space(xyzw),
|
||||
//ProjectionType::Sfl(sfl) => sfl.world_to_clip_space(xyz),
|
||||
|
||||
// Cylindrical projections
|
||||
// MER, Mercator */
|
||||
ProjectionType::Mer(mer) => mer.world_to_clip_space(xyzw),
|
||||
ProjectionType::Mer(mer) => mer.world_to_clip_space(xyz),
|
||||
// CAR, */
|
||||
//ProjectionType::Car(car) => car.world_to_clip_space(xyzw),
|
||||
//ProjectionType::Car(car) => car.world_to_clip_space(xyz),
|
||||
// CEA, */
|
||||
//ProjectionType::Cea(cea) => cea.world_to_clip_space(xyzw),
|
||||
//ProjectionType::Cea(cea) => cea.world_to_clip_space(xyz),
|
||||
// CYP, */
|
||||
//ProjectionType::Cyp(cyp) => cyp.world_to_clip_space(xyzw),
|
||||
//ProjectionType::Cyp(cyp) => cyp.world_to_clip_space(xyz),
|
||||
// Conic projections
|
||||
// COD, */
|
||||
/*ProjectionType::Cod(cod) => {
|
||||
@@ -618,10 +605,10 @@ impl Projection for ProjectionType {
|
||||
let rot = Rotation::from_sky_position(
|
||||
&LonLatT::new(0.0_f64.to_angle(), (HALF_PI * 0.5).to_angle()).vector(),
|
||||
);
|
||||
cod.world_to_clip_space(&rot.rotate(&xyzw))
|
||||
cod.world_to_clip_space(&rot.rotate(&xyz))
|
||||
}*/
|
||||
// HEALPix hybrid projection
|
||||
//ProjectionType::Hpx(hpx) => hpx.world_to_clip_space(xyzw),
|
||||
//ProjectionType::Hpx(hpx) => hpx.world_to_clip_space(xyz),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -655,7 +642,7 @@ impl UniformType for ProjectionType {
|
||||
}
|
||||
}
|
||||
|
||||
use cgmath::Vector4;
|
||||
use cgmath::Vector3;
|
||||
|
||||
use mapproj::CanonicalProjection;
|
||||
pub trait Projection {
|
||||
@@ -664,24 +651,24 @@ pub trait Projection {
|
||||
/// # Arguments
|
||||
///
|
||||
/// * ``pos_clip_space`` - The position in the clipping space (orthonorlized space)
|
||||
fn clip_to_world_space(&self, xy_clip: &XYClip<f64>) -> Option<XYZWWorld<f64>>;
|
||||
fn clip_to_world_space(&self, xy_clip: &XYClip<f64>) -> Option<XYZWorld<f64>>;
|
||||
/// World to the clipping space deprojection
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * ``pos_world_space`` - The position in the world space
|
||||
fn world_to_clip_space(&self, pos_world_space: &XYZWWorld<f64>) -> Option<XYClip<f64>>;
|
||||
fn world_to_clip_space(&self, pos_world_space: &XYZWorld<f64>) -> Option<XYClip<f64>>;
|
||||
|
||||
/// (`alpha_p`, `delta_p`) in the WCS II paper from Mark Calabretta.
|
||||
#[inline]
|
||||
fn north_pole_world_space(&self) -> XYZWWorld<f64> {
|
||||
fn north_pole_world_space(&self) -> XYZWorld<f64> {
|
||||
// This is always defined
|
||||
self.clip_to_world_space(&XYClip::new(0.0, 1.0 - 1e-5))
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn south_pole_world_space(&self) -> XYZWWorld<f64> {
|
||||
fn south_pole_world_space(&self) -> XYZWorld<f64> {
|
||||
// This is always defined
|
||||
self.clip_to_world_space(&XYClip::new(0.0, -1.0 + 1e-5))
|
||||
.unwrap()
|
||||
@@ -704,7 +691,7 @@ where
|
||||
/// # Arguments
|
||||
///
|
||||
/// * ``pos_clip_space`` - The position in the clipping space (orthonorlized space)
|
||||
fn clip_to_world_space(&self, xy_clip: &XYClip<f64>) -> Option<XYZWWorld<f64>> {
|
||||
fn clip_to_world_space(&self, xy_clip: &XYClip<f64>) -> Option<XYZWorld<f64>> {
|
||||
let proj_bounds = self.bounds();
|
||||
// Scale the xy_clip space so that it maps the proj definition domain of mapproj
|
||||
let xy_mapproj = {
|
||||
@@ -729,7 +716,7 @@ where
|
||||
// Xmpp <-> Zal
|
||||
// -Ympp <-> Xal
|
||||
// Zmpp <-> Yal
|
||||
Vector4::new(-xyz_mapproj.y(), xyz_mapproj.z(), xyz_mapproj.x(), 1.0)
|
||||
Vector3::new(-xyz_mapproj.y(), xyz_mapproj.z(), xyz_mapproj.x())
|
||||
})
|
||||
}
|
||||
/// World to the clipping space deprojection
|
||||
@@ -737,7 +724,7 @@ where
|
||||
/// # Arguments
|
||||
///
|
||||
/// * ``pos_world_space`` - The position in the world space
|
||||
fn world_to_clip_space(&self, pos_world_space: &XYZWWorld<f64>) -> Option<XYClip<f64>> {
|
||||
fn world_to_clip_space(&self, pos_world_space: &XYZWorld<f64>) -> Option<XYClip<f64>> {
|
||||
// Xmpp <-> Zal
|
||||
// -Ympp <-> Xal
|
||||
// Zmpp <-> Yal
|
||||
@@ -792,7 +779,7 @@ mod tests {
|
||||
2.0 * ((xy.y as f64) / (h as f64)) - 1.0,
|
||||
);
|
||||
let rgb = if let Some(pos) = projection.clip_to_world_space(&clip_xy) {
|
||||
let pos = pos.truncate().normalize();
|
||||
let pos = pos.normalize();
|
||||
Rgb([
|
||||
((pos.x * 0.5 + 0.5) * 256.0) as u8,
|
||||
((pos.y * 0.5 + 0.5) * 256.0) as u8,
|
||||
|
||||
@@ -2,29 +2,31 @@ use crate::math;
|
||||
use crate::math::angle::ToAngle;
|
||||
use cgmath::{BaseFloat, InnerSpace};
|
||||
use cgmath::{Euler, Quaternion};
|
||||
use cgmath::{Vector3, Vector4};
|
||||
use cgmath::Vector3;
|
||||
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
// Internal structure of a rotation, a quaternion
|
||||
// All operations are done on it
|
||||
pub struct Rotation<S: BaseFloat>(pub Quaternion<S>);
|
||||
|
||||
use cgmath::{Matrix3, Matrix4};
|
||||
impl<S> From<&Matrix4<S>> for Rotation<S>
|
||||
use cgmath::{Matrix3};
|
||||
impl<S> From<&Matrix3<S>> for Rotation<S>
|
||||
where
|
||||
S: BaseFloat,
|
||||
{
|
||||
fn from(m: &Matrix4<S>) -> Self {
|
||||
let m: [[S; 4]; 4] = (*m).into();
|
||||
fn from(m: &Matrix3<S>) -> Self {
|
||||
/*let m: [[S; 3]; 3] = (*m).into();
|
||||
|
||||
let t = Matrix3::new(
|
||||
m[0][0], m[0][1], m[0][2], m[1][0], m[1][1], m[1][2], m[2][0], m[2][1], m[2][2],
|
||||
);
|
||||
m[0][0], m[0][1], m[0][2],
|
||||
m[1][0], m[1][1], m[1][2],
|
||||
m[2][0], m[2][1], m[2][2],
|
||||
);*/
|
||||
|
||||
Rotation(t.into())
|
||||
Rotation((*m).into())
|
||||
}
|
||||
}
|
||||
impl<S> From<&Rotation<S>> for Matrix4<S>
|
||||
impl<S> From<&Rotation<S>> for Matrix3<S>
|
||||
where
|
||||
S: BaseFloat,
|
||||
{
|
||||
@@ -53,7 +55,7 @@ where
|
||||
Rotation(q)
|
||||
}
|
||||
|
||||
pub fn get_rot_x(&self) -> Matrix4<S> {
|
||||
pub fn get_rot_x(&self) -> Matrix3<S> {
|
||||
let mut q = self.0;
|
||||
|
||||
q.v.z = S::zero();
|
||||
@@ -66,7 +68,7 @@ where
|
||||
q.into()
|
||||
}
|
||||
|
||||
pub fn get_rot_y(&self) -> Matrix4<S> {
|
||||
pub fn get_rot_y(&self) -> Matrix3<S> {
|
||||
let mut q = self.0;
|
||||
|
||||
q.v.x = S::zero();
|
||||
@@ -79,7 +81,7 @@ where
|
||||
q.into()
|
||||
}
|
||||
|
||||
pub fn get_rot_z(&self) -> Matrix4<S> {
|
||||
pub fn get_rot_z(&self) -> Matrix3<S> {
|
||||
let mut q = self.0;
|
||||
|
||||
q.v.x = S::zero();
|
||||
@@ -102,36 +104,36 @@ where
|
||||
Rotation(*q)
|
||||
}
|
||||
|
||||
pub fn from_matrix4(mat: &Matrix4<S>) -> Rotation<S> {
|
||||
pub fn from_matrix3(mat: &Matrix3<S>) -> Rotation<S> {
|
||||
mat.into()
|
||||
}
|
||||
|
||||
// Define a rotation from an axis and a angle
|
||||
pub fn from_axis_angle(axis: &Vector3<S>, angle: Angle<S>) -> Rotation<S> {
|
||||
let angle: Rad<S> = angle.into();
|
||||
let mat4 = Matrix4::from_axis_angle(axis.normalize(), angle);
|
||||
(&mat4).into()
|
||||
let mat = Matrix3::from_axis_angle(axis.normalize(), angle);
|
||||
(&mat).into()
|
||||
}
|
||||
|
||||
// Define a rotation from a normalized vector
|
||||
pub fn from_sky_position(pos: &Vector3<S>) -> Rotation<S> {
|
||||
let (lon, lat) = math::lonlat::xyz_to_radec(&pos);
|
||||
|
||||
let rot_y = Matrix4::from_angle_y(lon);
|
||||
let rot_x = Matrix4::from_angle_x(-lat);
|
||||
let rot_y = Matrix3::from_angle_y(lon);
|
||||
let rot_x = Matrix3::from_angle_x(-lat);
|
||||
|
||||
let mat4 = rot_y * rot_x;
|
||||
(&(mat4)).into()
|
||||
let mat = rot_y * rot_x;
|
||||
(&(mat)).into()
|
||||
}
|
||||
|
||||
// Apply a rotation to a position
|
||||
pub fn rotate(&self, pos_world_space: &Vector4<S>) -> Vector4<S> {
|
||||
let w2m: &Matrix4<S> = &self.into();
|
||||
pub fn rotate(&self, pos_world_space: &Vector3<S>) -> Vector3<S> {
|
||||
let w2m: &Matrix3<S> = &self.into();
|
||||
|
||||
w2m * pos_world_space
|
||||
}
|
||||
pub fn inv_rotate(&self, pos_model_space: &Vector4<S>) -> Vector4<S> {
|
||||
let w2m: &Matrix4<S> = &self.into();
|
||||
pub fn inv_rotate(&self, pos_model_space: &Vector3<S>) -> Vector3<S> {
|
||||
let w2m: &Matrix3<S> = &self.into();
|
||||
let m2w = w2m.transpose();
|
||||
|
||||
m2w * pos_model_space
|
||||
@@ -154,7 +156,7 @@ where
|
||||
/// Equations come from this paper (Appendix 6):
|
||||
/// https://ntrs.nasa.gov/api/citations/19770024290/downloads/19770024290.pdf
|
||||
pub fn euler_yxz(&self) -> (Angle<S>, Angle<S>, Angle<S>) {
|
||||
let m: Matrix4<S> = self.0.into();
|
||||
let m: Matrix3<S> = self.0.into();
|
||||
|
||||
let a = m.x.z.atan2(m.z.z);
|
||||
let b = (-m.z.y).atan2((S::one() - m.z.y * m.z.y).sqrt());
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use super::bbox::BoundingBox;
|
||||
use crate::math::angle::ToAngle;
|
||||
|
||||
use crate::math::{lonlat::LonLatT, projection::coo_space::XYZWModel, MINUS_HALF_PI};
|
||||
use crate::math::{lonlat::LonLatT, projection::coo_space::XYZModel, MINUS_HALF_PI};
|
||||
use cgmath::Vector3;
|
||||
use healpix::sph_geom::coo3d::Vec3;
|
||||
use healpix::sph_geom::coo3d::{Coo3D, UnitVect3};
|
||||
@@ -38,11 +38,11 @@ pub enum Intersection {
|
||||
// The segment does not intersect the region
|
||||
Empty,
|
||||
// The segment does intersect the region
|
||||
Intersect { vertices: Box<[XYZWModel<f64>]> },
|
||||
Intersect { vertices: Box<[XYZModel<f64>]> },
|
||||
}
|
||||
|
||||
impl Region {
|
||||
pub fn from_vertices(vertices: &[XYZWModel<f64>], control_point: &XYZWModel<f64>) -> Self {
|
||||
pub fn from_vertices(vertices: &[XYZModel<f64>], control_point: &XYZModel<f64>) -> Self {
|
||||
let (vertices, (lon, lat)): (Vec<_>, (Vec<_>, Vec<_>)) = vertices
|
||||
.iter()
|
||||
.map(|v| {
|
||||
@@ -101,7 +101,7 @@ impl Region {
|
||||
let vertices = polygon
|
||||
.intersect_parallel_all(lat)
|
||||
.iter()
|
||||
.map(|v| XYZWModel::new(v.y(), v.z(), v.x(), 1.0))
|
||||
.map(|v| XYZModel::new(v.y(), v.z(), v.x()))
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
if !vertices.is_empty() {
|
||||
@@ -193,10 +193,10 @@ impl Region {
|
||||
let coo2 =
|
||||
Coo3D::from_sph_coo(lonlat2.lon().to_radians(), lonlat2.lat().to_radians());
|
||||
|
||||
let vertices: Vec<cgmath::Vector4<f64>> = polygon
|
||||
let vertices: Vec<cgmath::Vector3<f64>> = polygon
|
||||
.intersect_great_circle_arc_all(&coo1, &coo2)
|
||||
.iter()
|
||||
.map(|v| XYZWModel::new(v.y(), v.z(), v.x(), 1.0))
|
||||
.map(|v| XYZModel::new(v.y(), v.z(), v.x()))
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
if !vertices.is_empty() {
|
||||
@@ -225,10 +225,10 @@ impl Region {
|
||||
// The polygon is included inside the region
|
||||
Region::AllSky => Intersection::Included,
|
||||
Region::Polygon { polygon, .. } => {
|
||||
let vertices: Vec<cgmath::Vector4<f64>> = polygon
|
||||
let vertices: Vec<cgmath::Vector3<f64>> = polygon
|
||||
.intersect_great_circle_all(&UnitVect3::new_unsafe(n.z, n.x, n.y))
|
||||
.iter()
|
||||
.map(|v| XYZWModel::new(v.y(), v.z(), v.x(), 1.0))
|
||||
.map(|v| XYZModel::new(v.y(), v.z(), v.x()))
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
// Test whether a point on the meridian is included
|
||||
|
||||
@@ -232,7 +232,6 @@ impl Manager {
|
||||
// Cells that are of depth > 7 are not handled by the hashmap (limited to depth 7)
|
||||
// For these cells, we draw all the sources lying in the ancestor cell of depth 7 containing
|
||||
// this cell
|
||||
//if camera.get_aperture() > P::RASTER_THRESHOLD_ANGLE {
|
||||
if camera.get_field_of_view().is_allsky() {
|
||||
let cells = crate::healpix::cell::ALLSKY_HPX_CELLS_D0;
|
||||
|
||||
@@ -414,7 +413,7 @@ impl Catalog {
|
||||
}
|
||||
|
||||
// Cells are of depth <= 7
|
||||
fn update(&mut self, cells: &[HEALPixCell]) {
|
||||
pub fn update(&mut self, cells: &[HEALPixCell]) {
|
||||
let num_sources_in_fov = self.get_total_num_sources_in_fov(cells) as f32;
|
||||
// reset the sources in the frame
|
||||
let mut sources: Vec<_> = vec![];
|
||||
|
||||
@@ -66,8 +66,8 @@ impl Label {
|
||||
let m1: Vector3<_> = lonlat.vector();
|
||||
let m2 = (m1 + d * 1e-3).normalize();
|
||||
|
||||
let d1 = projection.model_to_screen_space(&m1.extend(1.0), camera)?;
|
||||
let d2 = projection.model_to_screen_space(&m2.extend(1.0), camera)?;
|
||||
let d1 = projection.model_to_screen_space(&m1, camera)?;
|
||||
let d2 = projection.model_to_screen_space(&m2, camera)?;
|
||||
|
||||
let dt = (d2 - d1).normalize();
|
||||
let db = Vector2::new(dt.y.abs(), dt.x.abs());
|
||||
@@ -126,7 +126,7 @@ impl Label {
|
||||
let m1: Vector3<_> = lonlat.vector();
|
||||
|
||||
let mut t = Vector3::new(-m1.z, 0.0, m1.x).normalize();
|
||||
let center = camera.get_center().truncate();
|
||||
let center = camera.get_center();
|
||||
|
||||
let dot_t_center = center.dot(t);
|
||||
if dot_t_center.abs() < 1e-4 {
|
||||
@@ -137,8 +137,8 @@ impl Label {
|
||||
|
||||
let m2 = (m1 + t * 1e-3).normalize();
|
||||
|
||||
let d1 = projection.model_to_screen_space(&m1.extend(1.0), camera)?;
|
||||
let d2 = projection.model_to_screen_space(&m2.extend(1.0), camera)?;
|
||||
let d1 = projection.model_to_screen_space(&m1, camera)?;
|
||||
let d2 = projection.model_to_screen_space(&m2, camera)?;
|
||||
|
||||
let dt = (d2 - d1).normalize();
|
||||
let db = Vector2::new(dt.y.abs(), dt.x.abs());
|
||||
|
||||
@@ -59,7 +59,7 @@ fn generate_xyz_position(projection: &ProjectionType) -> Vec<f32> {
|
||||
2.0 * ((xy.y as f64) / (h as f64)) - 1.0,
|
||||
);
|
||||
if let Some(pos) = projection.clip_to_world_space(&clip_xy) {
|
||||
let pos = pos.truncate().normalize();
|
||||
let pos = pos.normalize();
|
||||
/*let mut d: u32 = 0;
|
||||
d |= 3 << 30;
|
||||
d |= (((pos.z * 0.5 + 0.5) * (1024.0 as f64)) as u32) << 20;
|
||||
|
||||
@@ -11,7 +11,7 @@ fn is_too_large(cell: &HEALPixCell, camera: &CameraViewPort, projection: &Projec
|
||||
.vertices()
|
||||
.iter()
|
||||
.filter_map(|(lon, lat)| {
|
||||
let vertex = crate::math::lonlat::radec_to_xyzw(lon.to_angle(), lat.to_angle());
|
||||
let vertex = crate::math::lonlat::radec_to_xyz(lon.to_angle(), lat.to_angle());
|
||||
projection.icrs_celestial_to_screen_space(&vertex, camera)
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use cgmath::Vector4;
|
||||
use cgmath::Vector3;
|
||||
use std::ops::RangeInclusive;
|
||||
use wcs::ImgXY;
|
||||
|
||||
@@ -195,14 +195,14 @@ pub fn vertices(
|
||||
.map(|(y, uvy)| {
|
||||
x_it.clone().map(move |(x, uvx)| {
|
||||
let ndc = if let Some(xyz) = wcs.unproj_xyz(&ImgXY::new(x as f64, y as f64)) {
|
||||
let xyzw = crate::coosys::apply_coo_system(
|
||||
let xyz = crate::coosys::apply_coo_system(
|
||||
CooSystem::ICRS,
|
||||
camera.get_coo_system(),
|
||||
&Vector4::new(xyz.y(), xyz.z(), xyz.x(), 1.0),
|
||||
&Vector3::new(xyz.y(), xyz.z(), xyz.x()),
|
||||
);
|
||||
|
||||
projection
|
||||
.model_to_normalized_device_space(&xyzw, camera)
|
||||
.model_to_normalized_device_space(&xyz, camera)
|
||||
.map(|v| [v.x as f32, v.y as f32])
|
||||
} else {
|
||||
None
|
||||
|
||||
@@ -9,7 +9,7 @@ use std::marker::Unpin;
|
||||
use std::vec;
|
||||
|
||||
use al_api::coo_system::CooSystem;
|
||||
use cgmath::Vector4;
|
||||
use cgmath::Vector3;
|
||||
use futures::stream::TryStreamExt;
|
||||
use futures::AsyncRead;
|
||||
|
||||
@@ -265,7 +265,7 @@ impl Image {
|
||||
let inside = crate::coosys::apply_coo_system(
|
||||
CooSystem::ICRS,
|
||||
coo_sys,
|
||||
&Vector4::new(center_xyz.y(), center_xyz.z(), center_xyz.x(), 1.0),
|
||||
&Vector3::new(center_xyz.y(), center_xyz.z(), center_xyz.x()),
|
||||
);
|
||||
|
||||
let vertices = [
|
||||
@@ -285,7 +285,7 @@ impl Image {
|
||||
crate::coosys::apply_coo_system(
|
||||
CooSystem::ICRS,
|
||||
coo_sys,
|
||||
&Vector4::new(xyz.y(), xyz.z(), xyz.x(), 1.0),
|
||||
&Vector3::new(xyz.y(), xyz.z(), xyz.x()),
|
||||
)
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
@@ -556,7 +556,7 @@ impl Image {
|
||||
let inside = crate::coosys::apply_coo_system(
|
||||
CooSystem::ICRS,
|
||||
self.coo_sys,
|
||||
&Vector4::new(center_xyz.y(), center_xyz.z(), center_xyz.x(), 1.0),
|
||||
&Vector3::new(center_xyz.y(), center_xyz.z(), center_xyz.x()),
|
||||
);
|
||||
|
||||
let vertices = [
|
||||
@@ -580,7 +580,7 @@ impl Image {
|
||||
crate::coosys::apply_coo_system(
|
||||
CooSystem::ICRS,
|
||||
self.coo_sys,
|
||||
&Vector4::new(xyz.y(), xyz.z(), xyz.x(), 1.0),
|
||||
&Vector3::new(xyz.y(), xyz.z(), xyz.x()),
|
||||
)
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
@@ -32,8 +32,8 @@ pub fn project(
|
||||
let v1: Vector3<_> = lonlat1.vector();
|
||||
let v2: Vector3<_> = lonlat2.vector();
|
||||
|
||||
let p1 = projection.model_to_normalized_device_space(&v1.extend(1.0), camera);
|
||||
let p2 = projection.model_to_normalized_device_space(&v2.extend(1.0), camera);
|
||||
let p1 = projection.model_to_normalized_device_space(&v1, camera);
|
||||
let p2 = projection.model_to_normalized_device_space(&v2, camera);
|
||||
|
||||
match (p1, p2) {
|
||||
(Some(_), Some(_)) => {
|
||||
@@ -63,14 +63,14 @@ fn sub_valid_domain(
|
||||
projection: &ProjectionType,
|
||||
camera: &CameraViewPort,
|
||||
) -> (XYZModel<f64>, XYZModel<f64>) {
|
||||
let d_alpha = camera.get_aperture().to_radians() * 0.02;
|
||||
let d_alpha = camera.get_aperture() * 0.02;
|
||||
|
||||
let mut vv = valid_v;
|
||||
let mut vi = invalid_v;
|
||||
while crate::math::vector::angle3(&vv, &vi).to_radians() > d_alpha {
|
||||
let vm = (vv + vi).normalize();
|
||||
// check whether is it defined or not
|
||||
if let Some(_) = projection.model_to_normalized_device_space(&vm.extend(1.0), camera) {
|
||||
if let Some(_) = projection.model_to_normalized_device_space(&vm, camera) {
|
||||
vv = vm;
|
||||
} else {
|
||||
vi = vm;
|
||||
@@ -89,13 +89,13 @@ fn project_line(
|
||||
projection: &ProjectionType,
|
||||
iter: usize,
|
||||
) -> bool {
|
||||
let p1 = projection.model_to_normalized_device_space(&v1.extend(1.0), camera);
|
||||
let p2 = projection.model_to_normalized_device_space(&v2.extend(1.0), camera);
|
||||
let p1 = projection.model_to_normalized_device_space(&v1, camera);
|
||||
let p2 = projection.model_to_normalized_device_space(&v2, camera);
|
||||
|
||||
if iter < MAX_ITERATION {
|
||||
// Project them. We are always facing the camera
|
||||
let vm = (v1 + v2).normalize();
|
||||
let pm = projection.model_to_normalized_device_space(&vm.extend(1.0), camera);
|
||||
let pm = projection.model_to_normalized_device_space(&vm, camera);
|
||||
|
||||
match (p1, pm, p2) {
|
||||
(Some(p1), Some(pm), Some(p2)) => {
|
||||
|
||||
@@ -60,7 +60,7 @@ pub fn project(lat: f64, mut lon1: f64, lon2: f64, camera: &CameraViewPort, proj
|
||||
// * valid_lon and invalid_lon are well defined, i.e. they can be between [-PI; PI] or [0, 2PI] depending
|
||||
// whether they cross or not the zero meridian
|
||||
fn sub_valid_domain(lat: f64, valid_lon: f64, invalid_lon: f64, projection: &ProjectionType, camera: &CameraViewPort) -> (f64, f64) {
|
||||
let d_alpha = camera.get_aperture().to_radians() * 0.02;
|
||||
let d_alpha = camera.get_aperture() * 0.02;
|
||||
|
||||
let mut l_valid = valid_lon;
|
||||
let mut l_invalid = invalid_lon;
|
||||
|
||||
@@ -56,7 +56,7 @@ impl MOCHierarchy {
|
||||
let mut d = self.full_res_depth as usize;
|
||||
|
||||
let hpx_cell_size_rad =
|
||||
(smallest_cell_size_px / w_screen_px) * camera.get_aperture().to_radians();
|
||||
(smallest_cell_size_px / w_screen_px) * camera.get_aperture();
|
||||
|
||||
while d > 0 {
|
||||
//self.mocs[d].cell_indices_in_view(camera);
|
||||
|
||||
@@ -14,8 +14,6 @@ use crate::tile_fetcher::TileFetcherQueue;
|
||||
|
||||
use al_core::image::format::ChannelType;
|
||||
|
||||
pub use catalog::Manager;
|
||||
|
||||
use al_api::color::ColorRGB;
|
||||
use al_api::hips::HiPSCfg;
|
||||
use al_api::hips::ImageMetadata;
|
||||
|
||||
@@ -56,6 +56,7 @@ pub unsafe fn transmute_vec_to_u8<I>(mut s: Vec<I>) -> Vec<u8> {
|
||||
std::mem::transmute(s)
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub unsafe fn transmute_vec<I, O>(mut s: Vec<I>) -> Result<Vec<O>, &'static str> {
|
||||
if std::mem::size_of::<I>() % std::mem::size_of::<O>() > 0 {
|
||||
Err("The input type is not a multiple of the output type")
|
||||
@@ -100,15 +101,13 @@ pub(super) fn merge_overlapping_intervals(mut intervals: Vec<Range<usize>>) -> V
|
||||
Execute a closure after some delay. This mimics the javascript built-in setTimeout procedure.
|
||||
*/
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
pub(crate) fn set_timeout<F>(f: F, delay: i32)
|
||||
use {std::cell::Cell, std::rc::Rc, wasm_bindgen::closure::Closure, wasm_bindgen::JsCast};
|
||||
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
pub(crate) fn set_timeout<F>(f: F, delay: i32) -> Rc<Cell<i32>>
|
||||
where
|
||||
F: 'static + FnOnce() -> (),
|
||||
{
|
||||
use std::cell::Cell;
|
||||
use std::rc::Rc;
|
||||
use wasm_bindgen::closure::Closure;
|
||||
use wasm_bindgen::JsCast;
|
||||
|
||||
let timeout_id = Rc::new(Cell::new(0));
|
||||
let t_id = timeout_id.clone();
|
||||
let cb = Closure::once_into_js(move || {
|
||||
@@ -131,4 +130,24 @@ where
|
||||
)
|
||||
.unwrap(),
|
||||
);
|
||||
|
||||
timeout_id
|
||||
}
|
||||
/*
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
pub(crate) fn debounce<F1, F2>(f: F1, delay: i32) -> Closure<F2>
|
||||
where
|
||||
F1: 'static + FnOnce() -> (),
|
||||
F2: 'static + FnOnce() -> (),
|
||||
{
|
||||
let timeout_id = Rc::new(Cell::new(0));
|
||||
|
||||
Closure::once(move || {
|
||||
web_sys::window()
|
||||
.unwrap()
|
||||
.clear_timeout_with_handle(timeout_id.get());
|
||||
|
||||
timeout_id.set(set_timeout(f, delay));
|
||||
})
|
||||
}
|
||||
*/
|
||||
|
||||
@@ -5,8 +5,7 @@ layout (location = 1) in vec2 uv;
|
||||
layout (location = 2) in vec3 center;
|
||||
|
||||
uniform float current_time;
|
||||
uniform mat4 model;
|
||||
uniform mat4 inv_model;
|
||||
uniform mat3 inv_model;
|
||||
|
||||
uniform vec2 ndc_to_clip;
|
||||
uniform float czf;
|
||||
@@ -18,7 +17,7 @@ out vec3 out_p;
|
||||
#include ../projection/projection.glsl;
|
||||
|
||||
void main() {
|
||||
vec3 p = vec3(inv_model * vec4(center, 1.0f));
|
||||
vec3 p = inv_model * center;
|
||||
//p = check_inversed_longitude(p);
|
||||
|
||||
vec2 center_pos_clip_space = world2clip_aitoff(p);
|
||||
|
||||
@@ -5,7 +5,7 @@ layout (location = 1) in vec2 uv;
|
||||
layout (location = 2) in vec3 center;
|
||||
|
||||
uniform float current_time;
|
||||
uniform mat4 inv_model;
|
||||
uniform mat3 inv_model;
|
||||
|
||||
uniform vec2 ndc_to_clip;
|
||||
uniform float czf;
|
||||
@@ -17,7 +17,7 @@ out vec3 out_p;
|
||||
#include ../projection/projection.glsl;
|
||||
|
||||
void main() {
|
||||
vec3 p = vec3(inv_model * vec4(center, 1.0f));
|
||||
vec3 p = inv_model * center;
|
||||
//p = check_inversed_longitude(p);
|
||||
|
||||
vec2 center_pos_clip_space = world2clip_arc(p);
|
||||
|
||||
@@ -5,8 +5,7 @@ layout (location = 1) in vec2 uv;
|
||||
layout (location = 2) in vec3 center;
|
||||
|
||||
uniform float current_time;
|
||||
uniform mat4 model;
|
||||
uniform mat4 inv_model;
|
||||
uniform mat3 inv_model;
|
||||
|
||||
uniform vec2 ndc_to_clip;
|
||||
uniform float czf;
|
||||
@@ -19,7 +18,7 @@ out vec3 out_p;
|
||||
|
||||
|
||||
void main() {
|
||||
vec3 p = vec3(inv_model * vec4(center, 1.0f));
|
||||
vec3 p = inv_model * center;
|
||||
//p = check_inversed_longitude(p);
|
||||
|
||||
vec2 center_pos_clip_space = world2clip_healpix(p);
|
||||
|
||||
@@ -5,7 +5,7 @@ layout (location = 1) in vec2 uv;
|
||||
layout (location = 2) in vec3 center;
|
||||
|
||||
uniform float current_time;
|
||||
uniform mat4 inv_model;
|
||||
uniform mat3 inv_model;
|
||||
|
||||
uniform vec2 ndc_to_clip;
|
||||
uniform float czf;
|
||||
@@ -18,7 +18,7 @@ out vec3 out_p;
|
||||
|
||||
|
||||
void main() {
|
||||
vec3 p = vec3(inv_model * vec4(center, 1.0f));
|
||||
vec3 p = inv_model * center;
|
||||
//p = check_inversed_longitude(p);
|
||||
|
||||
vec2 center_pos_clip_space = world2clip_mercator(p);
|
||||
|
||||
@@ -5,7 +5,7 @@ layout (location = 1) in vec2 uv;
|
||||
layout (location = 2) in vec3 center;
|
||||
|
||||
uniform float current_time;
|
||||
uniform mat4 inv_model;
|
||||
uniform mat3 inv_model;
|
||||
|
||||
uniform vec2 ndc_to_clip;
|
||||
uniform float czf;
|
||||
@@ -18,7 +18,7 @@ out vec3 out_p;
|
||||
|
||||
|
||||
void main() {
|
||||
vec3 p = vec3(inv_model * vec4(center, 1.0f));
|
||||
vec3 p = inv_model * center;
|
||||
//p = check_inversed_longitude(p);
|
||||
|
||||
vec2 center_pos_clip_space = world2clip_mollweide(p);
|
||||
|
||||
@@ -5,7 +5,7 @@ layout (location = 1) in vec2 uv;
|
||||
layout (location = 2) in vec3 center;
|
||||
|
||||
uniform float current_time;
|
||||
uniform mat4 inv_model;
|
||||
uniform mat3 inv_model;
|
||||
|
||||
uniform vec2 ndc_to_clip;
|
||||
uniform float czf;
|
||||
@@ -18,7 +18,7 @@ out vec3 out_p;
|
||||
|
||||
|
||||
void main() {
|
||||
vec3 p = vec3(inv_model * vec4(center, 1.0f));
|
||||
vec3 p = inv_model * center;
|
||||
//p = check_inversed_longitude(p);
|
||||
|
||||
vec2 center_pos_clip_space = world2clip_orthographic(p);
|
||||
|
||||
@@ -6,7 +6,7 @@ layout (location = 1) in vec2 uv;
|
||||
layout (location = 2) in vec3 center;
|
||||
|
||||
uniform float current_time;
|
||||
uniform mat4 inv_model;
|
||||
uniform mat3 inv_model;
|
||||
|
||||
uniform vec2 ndc_to_clip;
|
||||
uniform float czf;
|
||||
@@ -19,7 +19,7 @@ out vec3 out_p;
|
||||
|
||||
|
||||
void main() {
|
||||
vec3 p = vec3(inv_model * vec4(center, 1.0f));
|
||||
vec3 p = inv_model * center;
|
||||
//p = check_inversed_longitude(p);
|
||||
|
||||
vec2 center_pos_clip_space = world2clip_gnomonic(p);
|
||||
|
||||
@@ -12,7 +12,7 @@ out vec3 frag_uv_end;
|
||||
out float frag_blending_factor;
|
||||
|
||||
// current time in ms
|
||||
uniform mat4 inv_model;
|
||||
uniform mat3 inv_model;
|
||||
uniform vec2 ndc_to_clip;
|
||||
uniform float czf;
|
||||
uniform float current_time;
|
||||
@@ -21,9 +21,9 @@ uniform float current_time;
|
||||
|
||||
void main() {
|
||||
//vec3 xyz = lonlat2xyz(lonlat);
|
||||
vec4 p_w = inv_model * vec4(xyz, 1.0);
|
||||
vec3 p_w = inv_model * xyz;
|
||||
// 3. Process the projection
|
||||
vec2 p_clip = proj(p_w.xyz);
|
||||
vec2 p_clip = proj(p_w);
|
||||
|
||||
vec2 p_ndc = p_clip / (ndc_to_clip * czf);
|
||||
gl_Position = vec4(p_ndc, 0.0, 1.0);
|
||||
|
||||
@@ -10,12 +10,12 @@ out vec3 frag_pos;
|
||||
|
||||
uniform vec2 ndc_to_clip;
|
||||
uniform float czf;
|
||||
uniform mat4 model;
|
||||
uniform mat3 model;
|
||||
|
||||
void main() {
|
||||
vec2 uv = pos_clip_space * 0.5 + 0.5;
|
||||
|
||||
frag_pos = vec3(model * vec4(pos_world_space, 1.0));
|
||||
frag_pos = model * pos_world_space;
|
||||
|
||||
gl_Position = vec4(pos_clip_space / (ndc_to_clip * czf), 0.0, 1.0);
|
||||
out_clip_pos = pos_clip_space;
|
||||
|
||||
@@ -7,7 +7,7 @@ layout (location = 1) in vec3 uv;
|
||||
out vec3 frag_uv;
|
||||
|
||||
// current time in ms
|
||||
uniform mat4 inv_model;
|
||||
uniform mat3 inv_model;
|
||||
uniform vec2 ndc_to_clip;
|
||||
uniform float czf;
|
||||
|
||||
@@ -15,7 +15,7 @@ uniform float czf;
|
||||
|
||||
void main() {
|
||||
vec3 p_xyz = lonlat2xyz(lonlat);
|
||||
vec4 p_w = inv_model * vec4(p_xyz, 1.0);
|
||||
vec3 p_w = inv_model * p_xyz;
|
||||
// 3. Process the projection
|
||||
vec2 p_clip = proj(p_w.xyz);
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ layout (location = 0) in vec2 p_a_lonlat;
|
||||
layout (location = 1) in vec2 p_b_lonlat;
|
||||
layout (location = 2) in vec2 vertex;
|
||||
|
||||
uniform mat4 u_2world;
|
||||
uniform mat3 u_2world;
|
||||
uniform vec2 ndc_to_clip;
|
||||
uniform float czf;
|
||||
uniform float u_width;
|
||||
@@ -20,11 +20,11 @@ void main() {
|
||||
vec3 p_a_xyz = lonlat2xyz(p_a_lonlat);
|
||||
vec3 p_b_xyz = lonlat2xyz(p_b_lonlat);
|
||||
// 2. Convert to the world coo system
|
||||
vec4 p_a_w = u_2world * vec4(p_a_xyz, 1.0);
|
||||
vec4 p_b_w = u_2world * vec4(p_b_xyz, 1.0);
|
||||
vec3 p_a_w = u_2world * p_a_xyz;
|
||||
vec3 p_b_w = u_2world * p_b_xyz;
|
||||
// 3. Process the projection
|
||||
vec2 p_a_clip = proj(p_a_w.xyz);
|
||||
vec2 p_b_clip = proj(p_b_w.xyz);
|
||||
vec2 p_a_clip = proj(p_a_w);
|
||||
vec2 p_b_clip = proj(p_b_w);
|
||||
|
||||
vec2 da = p_a_clip - p_b_clip;
|
||||
l = dot(da, da);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
precision highp float;
|
||||
layout (location = 0) in vec2 lonlat;
|
||||
|
||||
uniform mat4 u_2world;
|
||||
uniform mat3 u_2world;
|
||||
uniform vec2 ndc_to_clip;
|
||||
uniform float czf;
|
||||
|
||||
@@ -12,9 +12,9 @@ void main() {
|
||||
// 1. Convert (lon, lat) into (x, y, z) space coo.
|
||||
vec3 p_xyz = lonlat2xyz(lonlat);
|
||||
// 2. Convert to the world coo system
|
||||
vec4 p_w = u_2world * vec4(p_xyz, 1.0);
|
||||
vec3 p_w = u_2world * p_xyz;
|
||||
// 3. Process the projection
|
||||
vec2 p_clip = proj(p_w.xyz);
|
||||
vec2 p_clip = proj(p_w);
|
||||
|
||||
vec2 p_ndc = p_clip / (ndc_to_clip * czf);
|
||||
gl_Position = vec4(p_ndc, 0.f, 1.f);
|
||||
|
||||
112
src/js/Aladin.js
112
src/js/Aladin.js
@@ -123,7 +123,8 @@ import { Polyline } from "./shapes/Polyline";
|
||||
* @property {boolean} [showReticle=true] - Whether to show the reticle.
|
||||
* @property {boolean} [showCatalog=true] - Whether to show the catalog.
|
||||
* @property {boolean} [showCooGrid=true] - Whether the coordinates grid should be shown at startup.
|
||||
*
|
||||
* @property {boolean} [inertia=true] - Whether mouse release triggers an inertia effect.
|
||||
* @property {boolean} [lockNorthUp=false] - If true, the north pole will always be up.
|
||||
* @property {boolean} [fullScreen=false] - Whether to start in full-screen mode.
|
||||
* @property {string} [reticleColor="rgb(178, 50, 178)"] - Color of the reticle in RGB format.
|
||||
* @property {number} [reticleSize=22] - Size of the reticle.
|
||||
@@ -223,29 +224,15 @@ import { Polyline } from "./shapes/Polyline";
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {string} ListenerCallback
|
||||
* String with possible values:
|
||||
* 'select' (deprecated, use objectsSelected instead),
|
||||
* 'objectsSelected',
|
||||
'objectClicked',
|
||||
'objectHovered',
|
||||
'objectHoveredStop',
|
||||
|
||||
'footprintClicked',
|
||||
'footprintHovered',
|
||||
|
||||
'positionChanged',
|
||||
'zoomChanged',
|
||||
|
||||
'click',
|
||||
'rightClickMove',
|
||||
'mouseMove',
|
||||
|
||||
'fullScreenToggled',
|
||||
'cooFrameChanged',
|
||||
'resizeChanged',
|
||||
'projectionChanged',
|
||||
'layerChanged'
|
||||
* @typedef {('select'|'objectsSelected'|'objectClicked'|'objectHovered'|'objectHoveredStop'|'footprintClicked'|'footprintHovered'|'positionChanged'|'zoomChanged'|'click'|'rightClickMove'|'mouseMove'|'wheelTriggered'|'fullScreenToggled'|'cooFrameChanged'|'resizeChanged'|'projectionChanged'|'layerChanged')} EventListener
|
||||
*
|
||||
* Some remarks:
|
||||
* <ul>
|
||||
* <li>'select' is <b>deprecated</b>, please use objectsSelected instead.</li>
|
||||
* <li>'mouseMove', 'click', 'wheelTriggered' are low level event listeners allowing the user to redefine basic functions. For example listening for 'wheelTriggered' will disable the default zooming heuristic then letting you to redefine it.</li>
|
||||
* <li>'objectsSelected', 'objectClicked', 'objectHovered', 'objectHoveredStop', 'footprintClicked', 'footprintHovered' are triggered when a catalog source/footprint has been clicked, hovered, ...
|
||||
* <li>Whenever the position (resp the fov) of the view has been changed 'positionChanged' (resp 'zoomChanged') is called</li>
|
||||
* </ul>
|
||||
*/
|
||||
|
||||
export let Aladin = (function () {
|
||||
@@ -518,12 +505,18 @@ export let Aladin = (function () {
|
||||
this.samp = new SAMPConnector(this);
|
||||
}
|
||||
|
||||
// lockNorthUp option
|
||||
this.lockNorthUp = options.lockNorthUp || false;
|
||||
if (this.lockNorthUp) {
|
||||
this.wasm.lockNorthUp();
|
||||
}
|
||||
|
||||
if (options.inertia !== undefined) {
|
||||
this.wasm.setInertia(options.inertia);
|
||||
}
|
||||
|
||||
if (options.northPoleOrientation) {
|
||||
this.setViewCenter2NorthPoleAngle(options.northPoleOrientation);
|
||||
this.setRotation(options.northPoleOrientation);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -822,7 +815,7 @@ export let Aladin = (function () {
|
||||
};
|
||||
|
||||
/**
|
||||
* Sets the field of view (FoV) of the Aladin instance to the specified angle in degrees.
|
||||
* Set the field of view (FoV) of the view in degrees.
|
||||
*
|
||||
* @memberof Aladin
|
||||
* @param {number} FoV - The angle of the field of view in degrees.
|
||||
@@ -832,11 +825,30 @@ export let Aladin = (function () {
|
||||
* aladin.setFoV(60);
|
||||
*/
|
||||
Aladin.prototype.setFoV = function (FoV) {
|
||||
this.view.setZoom(FoV);
|
||||
this.view.setFoV(FoV);
|
||||
};
|
||||
|
||||
Aladin.prototype.setFov = Aladin.prototype.setFoV;
|
||||
|
||||
/**
|
||||
* Set the screen scaling zoom factor of the view.
|
||||
*
|
||||
* @memberof Aladin
|
||||
* @param {number} zoomFactor - Scaling screen factor
|
||||
*/
|
||||
Aladin.prototype.setZoomFactor = function (zoomFactor) {
|
||||
this.view.setZoomFactor(zoomFactor);
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the screen scaling zoom factor of the view.
|
||||
*
|
||||
* @memberof Aladin
|
||||
*/
|
||||
Aladin.prototype.getZoomFactor = function () {
|
||||
return this.view.zoomFactor;
|
||||
};
|
||||
|
||||
// @API
|
||||
// (experimental) try to adjust the FoV to the given object name. Does nothing if object is not known from Simbad
|
||||
Aladin.prototype.adjustFovForObject = function (objectName) {
|
||||
@@ -1297,18 +1309,16 @@ export let Aladin = (function () {
|
||||
Aladin.prototype.zoomToFoV = function (fov, duration, complete) {
|
||||
duration = duration || 5;
|
||||
|
||||
this.zoomAnimationParams = null;
|
||||
|
||||
var zoomAnimationParams = {};
|
||||
zoomAnimationParams["start"] = new Date().getTime();
|
||||
zoomAnimationParams["end"] = new Date().getTime() + 1000 * duration;
|
||||
var fovArray = this.getFov();
|
||||
zoomAnimationParams["fovStart"] = Math.max(fovArray[0], fovArray[1]);
|
||||
zoomAnimationParams["fovEnd"] = fov;
|
||||
zoomAnimationParams["complete"] = complete;
|
||||
zoomAnimationParams["running"] = true;
|
||||
|
||||
this.zoomAnimationParams = zoomAnimationParams;
|
||||
this.zoomAnimationParams = {
|
||||
start: new Date().getTime(),
|
||||
end: new Date().getTime() + 1000 * duration,
|
||||
fovStart: Math.max(fovArray[0], fovArray[1]),
|
||||
fovEnd: fov,
|
||||
complete: complete,
|
||||
running: true,
|
||||
};
|
||||
doZoomAnimation(this);
|
||||
};
|
||||
|
||||
@@ -1998,7 +2008,7 @@ export let Aladin = (function () {
|
||||
* view in the counter clockwise order (or towards the east)
|
||||
*/
|
||||
Aladin.prototype.setRotation = function (rotation) {
|
||||
this.view.setViewCenter2NorthPoleAngle(rotation);
|
||||
this.view.setRotation(rotation);
|
||||
};
|
||||
|
||||
|
||||
@@ -2011,7 +2021,7 @@ export let Aladin = (function () {
|
||||
* @returns {number} - Angle between the position center and the north pole
|
||||
*/
|
||||
Aladin.prototype.getRotation = function () {
|
||||
return this.view.wasm.getViewCenter2NorthPoleAngle();
|
||||
return this.view.wasm.getRotation();
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -2114,6 +2124,7 @@ export let Aladin = (function () {
|
||||
"click",
|
||||
"rightClickMove",
|
||||
"mouseMove",
|
||||
"wheelTriggered",
|
||||
|
||||
"fullScreenToggled",
|
||||
"cooFrameChanged",
|
||||
@@ -2126,14 +2137,14 @@ export let Aladin = (function () {
|
||||
* Listen aladin for specific events
|
||||
*
|
||||
* @memberof Aladin
|
||||
* @param {ListenerCallback} what - e.g. objectHovered, select, zoomChanged, positionChanged
|
||||
* @param {EventListener} what - e.g. objectHovered, select, zoomChanged, positionChanged, wheelTriggered
|
||||
* @param {function} myFunction - a callback function.
|
||||
* Note: <ul>
|
||||
* <li>positionChanged and zoomChanged are throttled every 100ms.</li>
|
||||
* <li>positionChanged's callback gives an object having ra and dec keywords of the current position in ICRS frame. See the below example.</li>
|
||||
* </ul>
|
||||
* @example
|
||||
// define function triggered when a source is hovered
|
||||
// Define a function triggered when a source is hovered
|
||||
aladin.on('objectHovered', function(object, xyMouseCoords) {
|
||||
if (object) {
|
||||
msg = 'You hovered object ' + object.data.name + ' located at ' + object.ra + ', ' + object.dec + '; mouse coords - x: '
|
||||
@@ -2309,15 +2320,6 @@ export let Aladin = (function () {
|
||||
* aladin.setCooGrid({ enabled: true });
|
||||
*/
|
||||
Aladin.prototype.setCooGrid = function (options) {
|
||||
if (options.color) {
|
||||
// 1. the user has maybe given some
|
||||
options.color = new Color(options.color);
|
||||
// 3. convert from 0-255 to 0-1
|
||||
options.color.r /= 255;
|
||||
options.color.g /= 255;
|
||||
options.color.b /= 255;
|
||||
}
|
||||
|
||||
this.view.setGridOptions(options);
|
||||
};
|
||||
|
||||
@@ -2562,14 +2564,15 @@ export let Aladin = (function () {
|
||||
* Restrict the FoV range between a min and a max value
|
||||
*
|
||||
* @memberof Aladin
|
||||
* @param {number} minFoV - in degrees when zoom in at max. If undefined, the zooming in is not limited
|
||||
* @param {number} maxFoV - in degrees when zoom out at max. If undefined, the zooming out is not limited
|
||||
* @param {number} [minFoV=1.0 / 36000.0] - in degrees. By default, the zoom is limited to 0.1 arcsec
|
||||
* @param {number} maxFoV - in degrees. If undefined, zooming out is not limited
|
||||
*
|
||||
* @example
|
||||
* let aladin = A.aladin('#aladin-lite-div');
|
||||
* aladin.setFoVRange(30, 60);
|
||||
*/
|
||||
Aladin.prototype.setFoVRange = function (minFoV, maxFoV) {
|
||||
minFoV = minFoV || (1.0 / 36000.0);
|
||||
this.view.setFoVRange(minFoV, maxFoV);
|
||||
};
|
||||
|
||||
@@ -2706,16 +2709,11 @@ export let Aladin = (function () {
|
||||
* and the second element is the FoV height.
|
||||
*/
|
||||
Aladin.prototype.getFov = function () {
|
||||
// can go up to 1000 deg
|
||||
var fovX = this.view.fov;
|
||||
var s = this.getSize();
|
||||
|
||||
// constrain to the projection definition domain
|
||||
fovX = Math.min(fovX, this.view.projection.fov);
|
||||
var fovY = (s[1] / s[0]) * fovX;
|
||||
|
||||
fovY = Math.min(fovY, 180);
|
||||
// TODO : take into account AITOFF projection where fov can be larger than 180
|
||||
|
||||
return [fovX, fovY];
|
||||
};
|
||||
|
||||
@@ -37,6 +37,13 @@ export let MOC = (function() {
|
||||
* @class
|
||||
* @constructs MOC
|
||||
* @param {MOCOptions} options - Configuration options for the MOC
|
||||
* @property {boolean} perimeter - Show perimeter
|
||||
* @property {boolean} edge - Show the edges of HEALPix cells composing the MOC
|
||||
* @property {boolean} fill - Fill the MOC
|
||||
* @property {number} lineWidth - The width of lines used to draw the MOC
|
||||
* @property {number} opacity - Opacity of the edges, cells, etc... of a MOC
|
||||
* @property {string} color - Color of the edges/perimeter
|
||||
* @property {string} fillColor - Color to fill the MOC with
|
||||
*/
|
||||
let MOC = function(options) {
|
||||
//this.order = undefined;
|
||||
@@ -219,6 +226,33 @@ export let MOC = (function() {
|
||||
this.reportChange();
|
||||
}
|
||||
},
|
||||
perimeter: {
|
||||
get() {
|
||||
return this._perimeter;
|
||||
},
|
||||
set(perimeter) {
|
||||
this._perimeter = perimeter;
|
||||
this.reportChange();
|
||||
}
|
||||
},
|
||||
fill: {
|
||||
get() {
|
||||
return this._fill;
|
||||
},
|
||||
set(fill) {
|
||||
this._fill = fill;
|
||||
this.reportChange();
|
||||
}
|
||||
},
|
||||
edge: {
|
||||
get() {
|
||||
return this._edge;
|
||||
},
|
||||
set(edge) {
|
||||
this._edge = edge;
|
||||
this.reportChange();
|
||||
}
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -29,26 +29,26 @@
|
||||
*****************************************************************************/
|
||||
export let ProjectionEnum = {
|
||||
// Zenithal
|
||||
TAN: {id: 1, fov: 150, label: "Tangential"}, /* Gnomonic projection */
|
||||
STG: {id: 2, fov: 240, label: "Stereographic"}, /* Stereographic projection */
|
||||
SIN: {id: 3, fov: 1000, label: "Spheric"}, /* Orthographic */
|
||||
TAN: {id: 1, label: "Tangential"}, /* Gnomonic projection */
|
||||
STG: {id: 2, label: "Stereographic"}, /* Stereographic projection */
|
||||
SIN: {id: 3, label: "Spheric"}, /* Orthographic */
|
||||
// TODO: fix why the projection disappears at fov = 360.0
|
||||
ZEA: {id: 4, fov: 1000, label: "Zenital equal-area"}, /* Equal-area */
|
||||
ZEA: {id: 4, label: "Zenital equal-area"}, /* Equal-area */
|
||||
//FEYE: {id: 5, fov: 190, label: "fish eye"},
|
||||
//AIR: {id: 6, fov: 360, label: "airy"},
|
||||
//AZP: {fov: 180},
|
||||
//ARC: {id: 7, fov: 360, label: "zenital equidistant"},
|
||||
//NCP: {id: 8, fov: 180, label: "north celestial pole"},
|
||||
// Cylindrical
|
||||
MER: {id: 9, fov: 360, label: "Mercator"},
|
||||
MER: {id: 9, label: "Mercator"},
|
||||
//CAR: {id: 10, fov: 360, label: "plate carrée"},
|
||||
//CEA: {id: 11, fov: 360, label: "cylindrical equal area"},
|
||||
//CYP: {id: 12, fov: 360, label: "cylindrical perspective"},
|
||||
// Pseudo-cylindrical
|
||||
AIT: {id: 13, fov: 1000, label: "Hammer-Aïtoff"},
|
||||
AIT: {id: 13, label: "Hammer-Aïtoff"},
|
||||
//PAR: {id: 14, fov: 360, label: "parabolic"},
|
||||
//SFL: {id: 15, fov: 360, label: "sanson-flamsteed"},
|
||||
MOL: {id: 16, fov: 1000, label: "Mollweide"},
|
||||
MOL: {id: 16, label: "Mollweide"},
|
||||
// Conic
|
||||
//COD: {id: 17, fov: 360, label: "conic equidistant"},
|
||||
// Hybrid
|
||||
|
||||
@@ -194,6 +194,22 @@ Utils.throttle = function (fn, threshhold, scope) {
|
||||
}
|
||||
}
|
||||
|
||||
// Way of detecting if the computer has trackpad or a regular mouse wheel thanks to that post:
|
||||
// https://stackoverflow.com/questions/10744645/detect-touchpad-vs-mouse-in-javascript
|
||||
Utils.detectTrackPad = function (e) {
|
||||
var isTrackpad = false;
|
||||
if (e.wheelDeltaY) {
|
||||
if (e.wheelDeltaY === (e.deltaY * -3)) {
|
||||
isTrackpad = true;
|
||||
}
|
||||
}
|
||||
else if (e.deltaMode === 0) {
|
||||
isTrackpad = true;
|
||||
}
|
||||
|
||||
return isTrackpad
|
||||
}
|
||||
|
||||
|
||||
/* A LRU cache, inspired by https://gist.github.com/devinus/409353#file-gistfile1-js */
|
||||
// TODO : utiliser le LRU cache pour les tuiles images
|
||||
|
||||
271
src/js/View.js
271
src/js/View.js
@@ -49,6 +49,7 @@ import { Layout } from "./gui/Layout.js";
|
||||
import { SAMPActionButton } from "./gui/Button/SAMP.js";
|
||||
import { HiPS } from "./HiPS.js";
|
||||
import { Image } from "./Image.js";
|
||||
import { Color } from "./Color.js";
|
||||
|
||||
export let View = (function () {
|
||||
|
||||
@@ -97,6 +98,16 @@ export let View = (function () {
|
||||
console.error("Problem initializing Aladin Lite. Please contact the support by contacting Matthieu Baumann (baumannmatthieu0@gmail.com) or Thomas Boch (thomas.boch@astro.unistra.fr). You can also open an issue on the Aladin Lite github repository here: https://github.com/cds-astro/aladin-lite. Message error:" + e)
|
||||
}
|
||||
|
||||
this._defineProperties();
|
||||
|
||||
// I realized debouncing a little bit the resize process
|
||||
// prevents the div from flickering in white !
|
||||
// Let's keep that like that (with a very small debounced time of 2ms).
|
||||
this.debounceResize = Utils.debounce(() => {
|
||||
self.wasm.resize(self.width, self.height);
|
||||
self.updateZoomState()
|
||||
}, 2);
|
||||
|
||||
// Attach the drag and drop events to the view
|
||||
this.aladinDiv.ondrop = (event) => {
|
||||
const files = Utils.getDroppedFilesHandler(event);
|
||||
@@ -172,13 +183,14 @@ export let View = (function () {
|
||||
View.CALLBACKS_THROTTLE_TIME_MS,
|
||||
);
|
||||
|
||||
this.debounceProgCatOnZoom = Utils.debounce(() => {
|
||||
self.refreshProgressiveCats();
|
||||
self.drawAllOverlays();
|
||||
}, 300);
|
||||
|
||||
this.mustClearCatalog = true;
|
||||
this.mode = View.PAN;
|
||||
|
||||
// 0.1 arcsec
|
||||
this.minFoV = 1 / 36000;
|
||||
this.maxFoV = null;
|
||||
|
||||
this.healpixGrid = new HealpixGrid();
|
||||
this.then = Date.now();
|
||||
|
||||
@@ -186,10 +198,9 @@ export let View = (function () {
|
||||
lon = lat = 0;
|
||||
|
||||
// FoV init settings
|
||||
let initialFov = this.options.fov || 180.0;
|
||||
this.pinchZoomParameters = {
|
||||
isPinching: false, // true if a pinch zoom is ongoing
|
||||
initialFov: undefined,
|
||||
initialZoomFactor: undefined,
|
||||
initialDistance: undefined,
|
||||
};
|
||||
|
||||
@@ -198,7 +209,7 @@ export let View = (function () {
|
||||
this.setProjection(projName)
|
||||
|
||||
// Then set the zoom properly once the projection is defined
|
||||
this.setZoom(initialFov)
|
||||
this.fov = this.options.fov || 180.0
|
||||
|
||||
// Target position settings
|
||||
this.viewCenter = { lon, lat }; // position of center of view
|
||||
@@ -264,11 +275,6 @@ export let View = (function () {
|
||||
init(this);
|
||||
// listen to window resize and reshape canvases
|
||||
this.resizeTimer = null;
|
||||
/*if ('ontouchstart' in window) {
|
||||
Utils.on(document, 'orientationchange', (e) => {
|
||||
self.fixLayoutDimensions();
|
||||
})
|
||||
} else {*/
|
||||
|
||||
this.resizeObserver = new ResizeObserver(() => {
|
||||
self.fixLayoutDimensions();
|
||||
@@ -278,24 +284,6 @@ export let View = (function () {
|
||||
|
||||
self.fixLayoutDimensions();
|
||||
self.redraw()
|
||||
|
||||
// in some contexts (Jupyter notebook for instance), the parent div changes little time after Aladin Lite creation
|
||||
// this results in canvas dimension to be incorrect.
|
||||
// The following line tries to fix this issue
|
||||
/*setTimeout(function () {
|
||||
var computedWidth = $(self.aladinDiv).width();
|
||||
var computedHeight = $(self.aladinDiv).height();
|
||||
|
||||
if (self.width !== computedWidth || self.height === computedHeight) {
|
||||
self.fixLayoutDimensions();
|
||||
// As the WebGL backend has been resized correctly by
|
||||
// the previous call, we can get the zoom factor from it
|
||||
|
||||
self.setZoom(self.fov); // needed to force recomputation of displayed FoV
|
||||
}
|
||||
|
||||
self.requestRedraw();
|
||||
}, 1000);*/
|
||||
};
|
||||
|
||||
// different available modes
|
||||
@@ -311,6 +299,27 @@ export let View = (function () {
|
||||
View.CALLBACKS_THROTTLE_TIME_MS = 100; // minimum time between two consecutive callback calls
|
||||
|
||||
|
||||
View.prototype._defineProperties = function() {
|
||||
Object.defineProperties(this, {
|
||||
fov: {
|
||||
get() {
|
||||
return this.wasm.getFieldOfView();
|
||||
},
|
||||
set(newFov) {
|
||||
this.setFoV(newFov);
|
||||
}
|
||||
},
|
||||
zoomFactor: {
|
||||
get() {
|
||||
return this.wasm.getZoomFactor();
|
||||
},
|
||||
set(newZoomFactor) {
|
||||
this.setZoomFactor(newZoomFactor);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// (re)create needed canvases
|
||||
View.prototype.createCanvases = function () {
|
||||
let imageCanvas = this.aladinDiv.querySelector('.aladin-imageCanvas');
|
||||
@@ -346,17 +355,21 @@ export let View = (function () {
|
||||
};
|
||||
|
||||
View.prototype.setFoVRange = function(minFoV, maxFoV) {
|
||||
if (minFoV && maxFoV && minFoV > maxFoV) {
|
||||
var tmp = minFoV;
|
||||
minFoV = maxFoV;
|
||||
maxFoV = tmp;
|
||||
this.wasm.setFoVRange(minFoV, maxFoV)
|
||||
this.updateZoomState();
|
||||
}
|
||||
|
||||
View.prototype.getFoVRange = function() {
|
||||
let [minFoV, maxFoV] = this.wasm.getFoVRange();
|
||||
if (minFoV == -1.0) {
|
||||
minFoV = null;
|
||||
}
|
||||
|
||||
this.minFoV = minFoV || (1.0 / 36000);
|
||||
this.maxFoV = maxFoV;
|
||||
if (maxFoV == -1.0) {
|
||||
maxFoV = null;
|
||||
}
|
||||
|
||||
// reset the field of view
|
||||
this.setZoom(this.fov);
|
||||
return [minFoV, maxFoV]
|
||||
}
|
||||
|
||||
// called at startup and when window is resized
|
||||
@@ -391,15 +404,11 @@ export let View = (function () {
|
||||
this.catalogCtx.canvas.style.height = this.height + "px";
|
||||
this.catalogCtx.scale(window.devicePixelRatio, window.devicePixelRatio);
|
||||
|
||||
/*this.gridCtx = this.gridCanvas.getContext("2d");
|
||||
this.gridCtx.canvas.width = this.width;
|
||||
this.gridCtx.canvas.height = this.height;
|
||||
*/
|
||||
this.imageCtx = this.imageCanvas.getContext("webgl2");
|
||||
this.imageCtx.canvas.style.width = this.width + "px";
|
||||
this.imageCtx.canvas.style.height = this.height + "px";
|
||||
this.wasm.resize(this.width, this.height);
|
||||
this.setZoom(this.fov)
|
||||
|
||||
this.debounceResize();
|
||||
|
||||
pixelateCanvasContext(this.imageCtx, this.aladin.options.pixelateCanvas);
|
||||
|
||||
@@ -426,6 +435,7 @@ export let View = (function () {
|
||||
this.aladinDiv.style.removeProperty('line-height');
|
||||
|
||||
this.throttledDivResized();
|
||||
|
||||
};
|
||||
|
||||
var pixelateCanvasContext = function (ctx, pixelateFlag) {
|
||||
@@ -582,7 +592,7 @@ export let View = (function () {
|
||||
const [lon, lat] = view.aladin.pix2world(xymouse.x, xymouse.y, 'icrs');
|
||||
view.pointTo(lon, lat);
|
||||
// reset the rotation around center view
|
||||
view.setViewCenter2NorthPoleAngle(0.0);
|
||||
view.setRotation(0.0);
|
||||
}
|
||||
catch (err) {
|
||||
return;
|
||||
@@ -725,9 +735,13 @@ export let View = (function () {
|
||||
if (e.type === 'touchstart' && e.targetTouches && e.targetTouches.length >= 2) {
|
||||
view.dragging = false;
|
||||
|
||||
// Do not start the pinched rotation if the north up is locked
|
||||
if (view.aladin.lockNorthUp === true) {
|
||||
return;
|
||||
}
|
||||
|
||||
view.pinchZoomParameters.isPinching = true;
|
||||
var fov = view.wasm.getFieldOfView();
|
||||
view.pinchZoomParameters.initialFov = fov;
|
||||
view.pinchZoomParameters.initialZoomFactor = view.zoomFactor;
|
||||
view.pinchZoomParameters.initialDistance = Math.sqrt(Math.pow(e.targetTouches[0].clientX - e.targetTouches[1].clientX, 2) + Math.pow(e.targetTouches[0].clientY - e.targetTouches[1].clientY, 2));
|
||||
|
||||
view.fingersRotationParameters.initialViewAngleFromCenter = view.wasm.getViewCenter2NorthPoleAngle();
|
||||
@@ -814,7 +828,7 @@ export let View = (function () {
|
||||
|
||||
if ((e.type === 'touchend' || e.type === 'touchcancel') && view.pinchZoomParameters.isPinching) {
|
||||
view.pinchZoomParameters.isPinching = false;
|
||||
view.pinchZoomParameters.initialFov = view.pinchZoomParameters.initialDistance = undefined;
|
||||
view.pinchZoomParameters.initialZoomFactor = view.pinchZoomParameters.initialDistance = undefined;
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -1000,13 +1014,13 @@ export let View = (function () {
|
||||
// planetary survey case
|
||||
rotation -= fingerAngleDiff;
|
||||
}
|
||||
view.setViewCenter2NorthPoleAngle(rotation);
|
||||
view.setRotation(rotation);
|
||||
}
|
||||
|
||||
// zoom
|
||||
const dist = Math.sqrt(Math.pow(e.touches[0].clientX - e.touches[1].clientX, 2) + Math.pow(e.touches[0].clientY - e.touches[1].clientY, 2));
|
||||
const fov = Math.min(Math.max(view.pinchZoomParameters.initialFov * view.pinchZoomParameters.initialDistance / dist, 0.00002777777), view.projection.fov);
|
||||
view.setZoom(fov);
|
||||
const zoomFactor = view.pinchZoomParameters.initialZoomFactor * view.pinchZoomParameters.initialDistance / dist;
|
||||
view.zoomFactor = zoomFactor;
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -1134,10 +1148,6 @@ export let View = (function () {
|
||||
|
||||
// disable text selection on IE
|
||||
//Utils.on(view.aladinDiv, "selectstart", function () { return false; })
|
||||
/*var eventCount = 0;
|
||||
var eventCountStart;
|
||||
var isTouchPad;
|
||||
let id;*/
|
||||
|
||||
Utils.on(view.catalogCanvas, 'wheel', function (e) {
|
||||
e.preventDefault();
|
||||
@@ -1155,82 +1165,30 @@ export let View = (function () {
|
||||
xy: xymouse,
|
||||
});
|
||||
|
||||
if (view.rightClick) {
|
||||
return;
|
||||
}
|
||||
var onWheelTriggeredFunction = view.aladin.callbacksByEventName['wheelTriggered'];
|
||||
if (typeof onWheelTriggeredFunction === 'function') {
|
||||
onWheelTriggeredFunction(e)
|
||||
} else {
|
||||
// Default Aladin Lite zooming
|
||||
view.delta = e.deltaY || e.detail || (-e.wheelDelta);
|
||||
|
||||
if (!view.debounceProgCatOnZoom) {
|
||||
var self = view;
|
||||
view.debounceProgCatOnZoom = Utils.debounce(function () {
|
||||
self.refreshProgressiveCats();
|
||||
self.drawAllOverlays();
|
||||
}, 300);
|
||||
}
|
||||
|
||||
view.debounceProgCatOnZoom();
|
||||
//view.throttledZoomChanged();
|
||||
|
||||
// Zoom heuristic
|
||||
// First detect the device
|
||||
// See https://stackoverflow.com/questions/10744645/detect-touchpad-vs-mouse-in-javascript
|
||||
// for detecting the use of a touchpad
|
||||
/*view.isTouchPadDefined = isTouchPad || typeof isTouchPad !== "undefined";
|
||||
if (!view.isTouchPadDefined) {
|
||||
if (eventCount === 0) {
|
||||
view.delta = 0;
|
||||
eventCountStart = new Date().getTime();
|
||||
}
|
||||
|
||||
eventCount++;
|
||||
|
||||
if (new Date().getTime() - eventCountStart > 100) {
|
||||
if (eventCount > 10) {
|
||||
isTouchPad = true;
|
||||
} else {
|
||||
isTouchPad = false;
|
||||
}
|
||||
view.isTouchPadDefined = true;
|
||||
}
|
||||
}*/
|
||||
|
||||
// only ensure the touch pad test has been done before zooming
|
||||
/*if (!view.isTouchPadDefined) {
|
||||
return false;
|
||||
}*/
|
||||
|
||||
// touch pad defined
|
||||
view.delta = e.deltaY || e.detail || (-e.wheelDelta);
|
||||
|
||||
//if (isTouchPad) {
|
||||
if (!view.throttledTouchPadZoom) {
|
||||
view.throttledTouchPadZoom = () => {
|
||||
const factor = 2.0;
|
||||
let newFov = view.delta > 0 ? view.fov * factor : view.fov / factor;
|
||||
const factor = Utils.detectTrackPad(e) ? 1.04 : 1.2;
|
||||
const currZoomFactor = view.zoom.isZooming ? view.zoom.finalZoom : view.zoomFactor;
|
||||
//const currZoomFactor = view.wasm.getZoomFactor();
|
||||
let newZoomFactor = view.delta > 0 ? currZoomFactor * factor : currZoomFactor / factor;
|
||||
|
||||
// inside case
|
||||
view.zoom.apply({
|
||||
stop: newFov,
|
||||
duration: 100
|
||||
stop: newZoomFactor,
|
||||
duration: 100,
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
view.throttledTouchPadZoom();
|
||||
/*} else {
|
||||
if (!view.throttledMouseScrollZoom) {
|
||||
view.throttledMouseScrollZoom = () => {
|
||||
const factor = 2
|
||||
let newFov = view.delta > 0 ? view.fov * factor : view.fov / factor;
|
||||
// standard mouse wheel zooming
|
||||
view.zoom.apply({
|
||||
stop: newFov,
|
||||
duration: 100
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
view.throttledMouseScrollZoom()
|
||||
}*/
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
@@ -1546,45 +1504,44 @@ export let View = (function () {
|
||||
};
|
||||
|
||||
// Called for touchmove events
|
||||
View.prototype.setZoom = function (fov) {
|
||||
// limit the fov in function of the projection
|
||||
fov = Math.min(fov, this.projection.fov);
|
||||
View.prototype.setZoomFactor = function(zoomFactor) {
|
||||
this.wasm.setZoomFactor(zoomFactor);
|
||||
this.updateZoomState();
|
||||
}
|
||||
|
||||
// then clamp the fov between minFov and maxFov
|
||||
const minFoV = this.minFoV;
|
||||
const maxFoV = this.maxFoV;
|
||||
|
||||
if (minFoV) {
|
||||
fov = Math.max(fov, minFoV);
|
||||
}
|
||||
|
||||
if (maxFoV) {
|
||||
fov = Math.min(fov, maxFoV);
|
||||
}
|
||||
|
||||
this.wasm.setFieldOfView(fov);
|
||||
this.updateZoomState(fov);
|
||||
};
|
||||
View.prototype.setFoV = function(fov) {
|
||||
this.wasm.setFieldOfView(fov)
|
||||
this.updateZoomState();
|
||||
}
|
||||
|
||||
View.prototype.increaseZoom = function () {
|
||||
this.zoom.apply({
|
||||
stop: this.fov / 1.8,
|
||||
duration: 100
|
||||
stop: this.zoomFactor / 1.4,
|
||||
duration: 200,
|
||||
});
|
||||
}
|
||||
|
||||
View.prototype.decreaseZoom = function () {
|
||||
this.zoom.apply({
|
||||
stop: this.fov * 1.8,
|
||||
duration: 100
|
||||
stop: this.zoomFactor * 1.4,
|
||||
duration: 200,
|
||||
});
|
||||
}
|
||||
|
||||
View.prototype.setViewCenter2NorthPoleAngle = function(rotation) {
|
||||
this.wasm.setViewCenter2NorthPoleAngle(rotation);
|
||||
View.prototype.setRotation = function(rotation) {
|
||||
this.wasm.setRotation(rotation);
|
||||
}
|
||||
|
||||
View.prototype.setGridOptions = function (options) {
|
||||
if (options.color) {
|
||||
// 1. the user has maybe given some
|
||||
options.color = new Color(options.color);
|
||||
// 3. convert from 0-255 to 0-1
|
||||
options.color.r /= 255;
|
||||
options.color.g /= 255;
|
||||
options.color.b /= 255;
|
||||
}
|
||||
|
||||
this.gridCfg = {...this.gridCfg, ...options};
|
||||
this.wasm.setGridOptions(this.gridCfg);
|
||||
|
||||
@@ -1597,26 +1554,9 @@ export let View = (function () {
|
||||
|
||||
View.prototype.getGridOptions = function() {
|
||||
return this.gridCfg;
|
||||
}
|
||||
};
|
||||
|
||||
View.prototype.updateZoomState = function (fov) {
|
||||
// Get the new zoom values from the backend
|
||||
const newFov = fov || this.wasm.getFieldOfView()
|
||||
|
||||
// Disable the coo grid labels if we are too unzoomed
|
||||
const maxFovGridLabels = 360;
|
||||
if (this.fov <= maxFovGridLabels && newFov > maxFovGridLabels) {
|
||||
let gridOptions = this.getGridOptions()
|
||||
if (gridOptions) {
|
||||
this.originalShowLabels = gridOptions.showLabels;
|
||||
this.aladin.setCooGrid({showLabels: false});
|
||||
}
|
||||
|
||||
} else if (this.fov > maxFovGridLabels && newFov <= maxFovGridLabels) {
|
||||
this.aladin.setCooGrid({showLabels:this.originalShowLabels});
|
||||
}
|
||||
|
||||
this.fov = newFov;
|
||||
View.prototype.updateZoomState = function () {
|
||||
this.computeNorder();
|
||||
|
||||
let fovX = this.fov;
|
||||
@@ -1624,6 +1564,8 @@ export let View = (function () {
|
||||
fovX = Math.min(fovX, 360);
|
||||
fovY = Math.min(fovY, 180);
|
||||
|
||||
this.debounceProgCatOnZoom();
|
||||
|
||||
ALEvent.ZOOM_CHANGED.dispatchedTo(this.aladinDiv, { fovX, fovY });
|
||||
|
||||
this.throttledZoomChanged();
|
||||
@@ -1929,8 +1871,7 @@ export let View = (function () {
|
||||
|
||||
// Change the projection here
|
||||
this.wasm.setProjection(projName);
|
||||
let newProjFov = Math.min(this.fov, this.projection.fov);
|
||||
this.setZoom(newProjFov)
|
||||
this.updateZoomState()
|
||||
|
||||
const projFn = this.aladin.callbacksByEventName['projectionChanged'];
|
||||
(typeof projFn === 'function') && projFn(projName);
|
||||
|
||||
@@ -36,24 +36,16 @@ import { requestAnimFrame } from "./libs/RequestAnimationFrame.js";
|
||||
};
|
||||
|
||||
Zoom.prototype.apply = function(options) {
|
||||
let startZoom = options['start'] || this.view.fov;
|
||||
let startZoom = options['start'] || this.view.zoomFactor;
|
||||
let finalZoom = options['stop'] || undefined;
|
||||
let interpolationDuration = options['duration'] || 1000; // default to 1seconds
|
||||
if (!finalZoom)
|
||||
return;
|
||||
|
||||
// clamp the zoom to the view params minFov and maxFov and the projection bounds
|
||||
//finalZoom = Math.min(finalZoom, this.view.projection.fov);
|
||||
// then clamp the fov between minFov and maxFov
|
||||
const minFoV = this.view.minFoV;
|
||||
const maxFoV = this.view.maxFoV;
|
||||
|
||||
if (minFoV) {
|
||||
finalZoom = Math.max(finalZoom, minFoV);
|
||||
}
|
||||
|
||||
if (maxFoV) {
|
||||
finalZoom = Math.min(finalZoom, maxFoV);
|
||||
// Get a relative error for stopping the zooming
|
||||
const relativeErr = Math.abs(finalZoom - startZoom) * 0.01;
|
||||
const zoomFn = (zoom) => {
|
||||
this.view.setZoomFactor(zoom)
|
||||
}
|
||||
|
||||
this.finalZoom = finalZoom;
|
||||
@@ -97,6 +89,7 @@ import { requestAnimFrame } from "./libs/RequestAnimationFrame.js";
|
||||
if (self.stop) {
|
||||
self.isZooming = false;
|
||||
self.stop = false;
|
||||
self.finalZoom = undefined;
|
||||
} else {
|
||||
self.x = ( performance.now() - self.startTime ) / interpolationDuration;
|
||||
interpolatedZoom = Zoom.hermiteCubic.f(self.x, self.x1, self.x2, self.y1, self.y2, self.m1, self.m2);
|
||||
@@ -104,13 +97,13 @@ import { requestAnimFrame } from "./libs/RequestAnimationFrame.js";
|
||||
interpolatedZoom = Math.max(0, interpolatedZoom);
|
||||
|
||||
// Apply zoom level to map or perform any necessary rendering
|
||||
self.view.setZoom(interpolatedZoom);
|
||||
|
||||
self.fov = interpolatedZoom;
|
||||
zoomFn(interpolatedZoom);
|
||||
|
||||
if (self.x >= self.x2 || Math.abs(interpolatedZoom - self.finalZoom) < 1e-4) {
|
||||
self.view.setZoom(self.finalZoom);
|
||||
if (self.x >= self.x2 || Math.abs(interpolatedZoom - self.finalZoom) <= relativeErr) {
|
||||
zoomFn(self.finalZoom);
|
||||
|
||||
self.isZooming = false;
|
||||
} else if (self.view.wasm.atZoomBoundaries()) {
|
||||
self.isZooming = false;
|
||||
} else {
|
||||
// Request the next frame
|
||||
|
||||
Reference in New Issue
Block a user