diff --git a/codemeta.json b/codemeta.json index 16b0a9e3..e093b8ea 100644 --- a/codemeta.json +++ b/codemeta.json @@ -8,8 +8,8 @@ "dateModified": "2023-01-31", "issueTracker": "https://github.com/cds-astro/aladin-lite/issues", "name": "Aladin Lite", - "version": "3.6.1", - "softwareVersion": "3.6.1", + "version": "3.6.2", + "softwareVersion": "3.6.2", "description": "An astronomical HiPS visualizer in the browser.", "identifier": "10.5281/zenodo.7638833", "applicationCategory": "Astronomy, Visualization", diff --git a/package.json b/package.json index d28671bc..b3840d6a 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "homepage": "https://aladin.u-strasbg.fr/", "name": "aladin-lite", "type": "module", - "version": "3.6.2", + "version": "3.6.3", "description": "An astronomical HiPS visualizer in the browser", "author": "Thomas Boch and Matthieu Baumann", "license": "GPL-3", diff --git a/src/core/Cargo.toml b/src/core/Cargo.toml index 2588d5f7..1c80a15c 100644 --- a/src/core/Cargo.toml +++ b/src/core/Cargo.toml @@ -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.2" +version = "3.6.3" authors = [ "baumannmatthieu0@gmail.com", "matthieu.baumann@astro.unistra.fr",] edition = "2018" diff --git a/src/core/src/camera/viewport.rs b/src/core/src/camera/viewport.rs index e4db7baa..9264940c 100644 --- a/src/core/src/camera/viewport.rs +++ b/src/core/src/camera/viewport.rs @@ -5,8 +5,8 @@ pub enum UserAction { Moving = 3, Starting = 4, } -use web_sys::WebGl2RenderingContext; +use web_sys::WebGl2RenderingContext; // Longitude reversed identity matrix const ID_R: &Matrix4 = &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, @@ -488,11 +488,11 @@ impl CameraViewPort { pub fn set_center(&mut self, lonlat: &LonLatT, proj: &ProjectionType) { let icrs_pos: Vector4<_> = lonlat.vector(); - let view_pos = CooSystem::ICRS.to(self.get_coo_system()) * icrs_pos; - let rot_to_center = Rotation::from_sky_position(&view_pos); + let center = (CooSystem::ICRS.to(self.get_coo_system()) * icrs_pos).truncate(); + let rot_to_center = Rotation::from_sky_position(¢er); let phi = self.get_center_pos_angle(); - let third_euler_rot = Rotation::from_axis_angle(&view_pos.truncate(), phi); + let third_euler_rot = Rotation::from_axis_angle(¢er, phi); let rot = third_euler_rot * rot_to_center; @@ -502,8 +502,9 @@ impl CameraViewPort { } pub fn set_center_pos_angle(&mut self, phi: Angle, proj: &ProjectionType) { - let rot_to_center = Rotation::from_sky_position(&self.center); - let third_euler_rot = Rotation::from_axis_angle(&self.center.truncate(), phi); + let c = self.center.truncate(); + let rot_to_center = Rotation::from_sky_position(&c); + let third_euler_rot = Rotation::from_axis_angle(&c, phi); let total_rot = third_euler_rot * rot_to_center; self.set_rotation(&total_rot, proj); @@ -523,7 +524,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); + let new_rotation = Rotation::from_sky_position(&new_center.truncate()); // Apply it to the center of the view self.set_rotation(&new_rotation, proj); diff --git a/src/core/src/lib.rs b/src/core/src/lib.rs index c3b94052..5723d7f5 100644 --- a/src/core/src/lib.rs +++ b/src/core/src/lib.rs @@ -523,7 +523,7 @@ impl WebClient { /// Get if the longitude axis is reversed #[wasm_bindgen(js_name = getLongitudeReversed)] - pub fn get_longitude_reversed(&mut self) -> bool { + pub fn get_longitude_reversed(&self) -> bool { self.app.get_longitude_reversed() } diff --git a/src/core/src/math/rotation.rs b/src/core/src/math/rotation.rs index 9db51b4b..a23684d5 100644 --- a/src/core/src/math/rotation.rs +++ b/src/core/src/math/rotation.rs @@ -1,8 +1,8 @@ use crate::math; +use crate::math::angle::ToAngle; use cgmath::{BaseFloat, InnerSpace}; use cgmath::{Euler, Quaternion}; use cgmath::{Vector3, Vector4}; -use crate::math::angle::ToAngle; #[derive(Clone, Copy, Debug)] // Internal structure of a rotation, a quaternion @@ -109,13 +109,13 @@ where // Define a rotation from an axis and a angle pub fn from_axis_angle(axis: &Vector3, angle: Angle) -> Rotation { let angle: Rad = angle.into(); - let mat4 = Matrix4::from_axis_angle(*axis, angle); + let mat4 = Matrix4::from_axis_angle(axis.normalize(), angle); (&mat4).into() } // Define a rotation from a normalized vector - pub fn from_sky_position(pos: &Vector4) -> Rotation { - let (lon, lat) = math::lonlat::xyzw_to_radec(&pos.normalize()); + pub fn from_sky_position(pos: &Vector3) -> Rotation { + 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); diff --git a/src/js/DefaultActionsForContextMenu.js b/src/js/DefaultActionsForContextMenu.js index 59861b3d..757bc8ad 100644 --- a/src/js/DefaultActionsForContextMenu.js +++ b/src/js/DefaultActionsForContextMenu.js @@ -35,6 +35,7 @@ import cameraIconUrl from '../../assets/icons/camera.svg' import targetIconUrl from '../../assets/icons/target.svg'; import uploadIconUrl from '../../assets/icons/upload.svg'; import selectIconUrl from '../../assets/icons/select.svg'; +import { Utils } from "./Utils"; export let DefaultActionsForContextMenu = (function () { @@ -55,7 +56,7 @@ export let DefaultActionsForContextMenu = (function () { return false; } - navigator.clipboard.writeText(text) + Utils.copy2Clipboard(text) .then(() => { msg = 'successful' if (aladinInstance.statusBar) { diff --git a/src/js/View.js b/src/js/View.js index f43f6bd9..5e21a622 100644 --- a/src/js/View.js +++ b/src/js/View.js @@ -926,9 +926,10 @@ export let View = (function () { xy: xymouse, }); - let dist = (() => { - return (xymouse.x - xystart.x)*(xymouse.x - xystart.x) + (xymouse.y - xystart.y)*(xymouse.y - xystart.y) - })(); + let dist; + if (xystart) { + dist = (xymouse.x - xystart.x)*(xymouse.x - xystart.x) + (xymouse.y - xystart.y)*(xymouse.y - xystart.y); + } if (e.type === 'touchmove' && xystart) { if (longTouchTimer && dist > 100) { diff --git a/src/js/gui/Button/ShareView.js b/src/js/gui/Button/ShareView.js index d5a91ac5..917d325f 100644 --- a/src/js/gui/Button/ShareView.js +++ b/src/js/gui/Button/ShareView.js @@ -22,7 +22,7 @@ import shareIconUrl from '../../../../assets/icons/share.svg'; import cameraIconUrl from '../../../../assets/icons/camera.svg'; import linkIconUrl from '../../../../assets/icons/link.svg'; import jupyterIconUrl from '../../../../assets/icons/jupyter.svg'; - +import { Utils } from "../../Utils"; /****************************************************************************** * Aladin Lite project * @@ -62,15 +62,16 @@ import jupyterIconUrl from '../../../../assets/icons/jupyter.svg'; }, action(o) { var url = aladin.getShareURL(); - navigator.clipboard.writeText(url); - - if (aladin.statusBar) { - aladin.statusBar.appendMessage({ - message: 'View URL saved into your clipboard!', - duration: 2000, - type: 'info' + Utils.copy2Clipboard(url) + .then(() => { + if (aladin.statusBar) { + aladin.statusBar.appendMessage({ + message: 'View URL saved into your clipboard!', + duration: 2000, + type: 'info' + }) + } }) - } } }, {