mirror of
https://github.com/cds-astro/aladin-lite.git
synced 2026-06-12 19:11:42 -07:00
cargo clippy & fmt
This commit is contained in:
@@ -30,7 +30,7 @@
|
|||||||
fov *= 0.997;
|
fov *= 0.997;
|
||||||
rotation += 0.07;
|
rotation += 0.07;
|
||||||
|
|
||||||
aladin.setViewCenter2NorthPoleAngle(rotation)
|
aladin.setRotation(rotation)
|
||||||
aladin.setFoV(fov);
|
aladin.setFoV(fov);
|
||||||
|
|
||||||
if (fov < 3 && fov > 0.5) {
|
if (fov < 3 && fov > 0.5) {
|
||||||
|
|||||||
+1
-1
@@ -51,7 +51,7 @@ fn generate_shaders() -> std::result::Result<(), Box<dyn Error>> {
|
|||||||
fs::write(tmp_path.clone(), &src)?;
|
fs::write(tmp_path.clone(), &src)?;
|
||||||
|
|
||||||
Command::new("mono")
|
Command::new("mono")
|
||||||
.args(&[
|
.args([
|
||||||
"/Users/matthieubaumann/Downloads/shader_minifier.exe",
|
"/Users/matthieubaumann/Downloads/shader_minifier.exe",
|
||||||
"--format",
|
"--format",
|
||||||
"text",
|
"text",
|
||||||
|
|||||||
+1
-1
@@ -1759,7 +1759,7 @@ impl App {
|
|||||||
|
|
||||||
if let Some(cur_pos) = self.projection.screen_to_model_space(&next_s, &self.camera)
|
if let Some(cur_pos) = self.projection.screen_to_model_space(&next_s, &self.camera)
|
||||||
{
|
{
|
||||||
let d = math::vector::angle3(&prev_pos, &cur_pos);
|
let d = math::vector::angle3(prev_pos, &cur_pos);
|
||||||
let axis = prev_pos.cross(cur_pos).normalize();
|
let axis = prev_pos.cross(cur_pos).normalize();
|
||||||
|
|
||||||
self.camera
|
self.camera
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ use cgmath::Vector3;
|
|||||||
use crate::camera::CameraViewPort;
|
use crate::camera::CameraViewPort;
|
||||||
use crate::math::angle::ToAngle;
|
use crate::math::angle::ToAngle;
|
||||||
use crate::math::projection::ProjectionType;
|
use crate::math::projection::ProjectionType;
|
||||||
use crate::time::{DeltaTime, Time};
|
use crate::time::Time;
|
||||||
/// State for inertia
|
/// State for inertia
|
||||||
pub struct Inertia {
|
pub struct Inertia {
|
||||||
// Initial angular distance
|
// Initial angular distance
|
||||||
|
|||||||
+2
-9
@@ -116,7 +116,6 @@ mod time;
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
camera::CameraViewPort, healpix::moc::SpaceMoc, math::lonlat::LonLatT, shader::ShaderManager,
|
camera::CameraViewPort, healpix::moc::SpaceMoc, math::lonlat::LonLatT, shader::ShaderManager,
|
||||||
time::DeltaTime,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
use al_api::color::{Color, ColorRGBA};
|
use al_api::color::{Color, ColorRGBA};
|
||||||
@@ -137,10 +136,6 @@ use math::angle::ArcDeg;
|
|||||||
pub struct WebClient {
|
pub struct WebClient {
|
||||||
// The app
|
// The app
|
||||||
app: App,
|
app: App,
|
||||||
|
|
||||||
// The time between the previous and the current
|
|
||||||
// frame
|
|
||||||
dt: DeltaTime,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
use al_api::hips::ImageMetadata;
|
use al_api::hips::ImageMetadata;
|
||||||
@@ -167,9 +162,7 @@ impl WebClient {
|
|||||||
|
|
||||||
let app = App::new(&gl, aladin_div, shaders, resources)?;
|
let app = App::new(&gl, aladin_div, shaders, resources)?;
|
||||||
|
|
||||||
let dt = DeltaTime::zero();
|
let webclient = WebClient { app };
|
||||||
|
|
||||||
let webclient = WebClient { app, dt };
|
|
||||||
|
|
||||||
Ok(webclient)
|
Ok(webclient)
|
||||||
}
|
}
|
||||||
@@ -196,7 +189,7 @@ impl WebClient {
|
|||||||
/// Whether the view is moving or not
|
/// Whether the view is moving or not
|
||||||
pub fn update(&mut self, dt: f64) -> Result<bool, JsValue> {
|
pub fn update(&mut self, dt: f64) -> Result<bool, JsValue> {
|
||||||
// dt refers to the time taking (in ms) rendering the previous frame
|
// dt refers to the time taking (in ms) rendering the previous frame
|
||||||
self.dt = DeltaTime::from_millis(dt as f32);
|
//self.dt = DeltaTime::from_millis(dt as f32);
|
||||||
|
|
||||||
// Update the application and get back the
|
// Update the application and get back the
|
||||||
// world coordinates of the center of projection in (ra, dec)
|
// world coordinates of the center of projection in (ra, dec)
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
use crate::math;
|
use crate::math;
|
||||||
use crate::math::angle::ToAngle;
|
use crate::math::angle::ToAngle;
|
||||||
use cgmath::One;
|
|
||||||
use cgmath::Vector3;
|
use cgmath::Vector3;
|
||||||
use cgmath::{BaseFloat, InnerSpace};
|
use cgmath::{BaseFloat, InnerSpace};
|
||||||
use cgmath::{Euler, Quaternion};
|
use cgmath::{Euler, Quaternion};
|
||||||
@@ -128,7 +127,7 @@ where
|
|||||||
let qy = Self::from_axis_angle(&Vector3::unit_y(), lon);
|
let qy = Self::from_axis_angle(&Vector3::unit_y(), lon);
|
||||||
let qx = Self::from_axis_angle(&Vector3::unit_x(), -lat);
|
let qx = Self::from_axis_angle(&Vector3::unit_x(), -lat);
|
||||||
|
|
||||||
(qy * qx)
|
qy * qx
|
||||||
}
|
}
|
||||||
|
|
||||||
/*pub fn from_sky_position(pos: &Vector3<S>) -> Rotation<S> {
|
/*pub fn from_sky_position(pos: &Vector3<S>) -> Rotation<S> {
|
||||||
|
|||||||
+4407
-4407
File diff suppressed because it is too large
Load Diff
+35
-22
@@ -785,11 +785,12 @@ export let View = (function () {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
view.pinchZoomParameters.isPinching = true;
|
view.pinchZoomParameters.isPinching = true;
|
||||||
view.pinchZoomParameters.initialZoomFactor = view.zoomFactor;
|
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.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();
|
view.fingersRotationParameters.initialViewAngleFromCenter = view.wasm.getRotation();
|
||||||
view.fingersRotationParameters.initialFingerAngle = Math.atan2(e.targetTouches[1].clientY - e.targetTouches[0].clientY, e.targetTouches[1].clientX - e.targetTouches[0].clientX) * 180.0 / Math.PI;
|
view.fingersRotationParameters.initialFingerAngle = Math.atan2(e.targetTouches[1].clientY - e.targetTouches[0].clientY, e.targetTouches[1].clientX - e.targetTouches[0].clientX) * 180.0 / Math.PI;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@@ -1275,6 +1276,20 @@ export let View = (function () {
|
|||||||
// disable text selection on IE
|
// disable text selection on IE
|
||||||
//Utils.on(view.aladinDiv, "selectstart", function () { return false; })
|
//Utils.on(view.aladinDiv, "selectstart", function () { return false; })
|
||||||
|
|
||||||
|
view.prevWheelTime = undefined;
|
||||||
|
|
||||||
|
function normalizeWheel(event) {
|
||||||
|
// Safari/Chrome on macOS: deltaMode = 0 (pixels), but trackpad steps are tiny
|
||||||
|
let scale = 1;
|
||||||
|
if (event.deltaMode === WheelEvent.DOM_DELTA_LINE) {
|
||||||
|
scale = 16; // assume ~16px per line
|
||||||
|
} else if (event.deltaMode === WheelEvent.DOM_DELTA_PAGE) {
|
||||||
|
scale = window.innerHeight;
|
||||||
|
}
|
||||||
|
return event.deltaY * scale;
|
||||||
|
}
|
||||||
|
view.zoomDelta = 0;
|
||||||
|
|
||||||
Utils.on(view.catalogCanvas, 'wheel', function (e) {
|
Utils.on(view.catalogCanvas, 'wheel', function (e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
@@ -1295,24 +1310,13 @@ export let View = (function () {
|
|||||||
if (typeof onWheelTriggeredFunction === 'function') {
|
if (typeof onWheelTriggeredFunction === 'function') {
|
||||||
onWheelTriggeredFunction(e)
|
onWheelTriggeredFunction(e)
|
||||||
} else {
|
} else {
|
||||||
// Default Aladin Lite zooming
|
// Default Aladin Lite zooming
|
||||||
view.delta = e.deltaY || e.detail || (-e.wheelDelta);
|
const normalizedDelta = e.deltaY && normalizeWheel(e) || e.detail || (-e.wheelDelta);
|
||||||
|
// Accumulate the normalized delta
|
||||||
if (!view.throttledTouchPadZoom) {
|
// We do not zoom because we cannot rely on "wheel" event
|
||||||
view.throttledTouchPadZoom = () => {
|
// being triggered at constant time steps
|
||||||
const factor = Utils.detectTrackPad(e) ? 1.07 : 1.2;
|
// The zoom is delayed to the redraw which is animation frame requested!
|
||||||
const currZoomFactor = view.zoom.isZooming ? view.zoom.finalZoom : view.zoomFactor;
|
view.zoomDelta += normalizedDelta;
|
||||||
let newZoomFactor = view.delta > 0 ? currZoomFactor * factor : currZoomFactor / factor;
|
|
||||||
|
|
||||||
// inside case
|
|
||||||
view.zoom.apply({
|
|
||||||
stop: newZoomFactor,
|
|
||||||
duration: 100,
|
|
||||||
});
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
view.throttledTouchPadZoom();
|
|
||||||
|
|
||||||
if (view.mode === View.TOOL_COLOR_PICKER) {
|
if (view.mode === View.TOOL_COLOR_PICKER) {
|
||||||
pickColor(xymouse);
|
pickColor(xymouse);
|
||||||
@@ -1386,16 +1390,25 @@ export let View = (function () {
|
|||||||
/**
|
/**
|
||||||
* redraw the whole view
|
* redraw the whole view
|
||||||
*/
|
*/
|
||||||
View.prototype.redraw = function (timestamp) {
|
View.prototype.redraw = function (now) {
|
||||||
// request another frame
|
// request another frame
|
||||||
requestAnimFrame(this.redrawClbk);
|
requestAnimFrame(this.redrawClbk);
|
||||||
|
|
||||||
// Elapsed time since last loop
|
// Elapsed time since last loop
|
||||||
const now = performance.now();
|
|
||||||
const elapsedTime = now - this.prevTime;
|
const elapsedTime = now - this.prevTime;
|
||||||
this.prevTime = now;
|
this.prevTime = now;
|
||||||
|
|
||||||
//this.dt = elapsedTime;
|
if (Math.abs(this.zoomDelta) > 1e-3) {
|
||||||
|
// Apply a fraction each frame (smoothing)
|
||||||
|
let step = this.zoomDelta * 0.2;
|
||||||
|
function wheelToZoomFactor(delta) {
|
||||||
|
const sensitivity = 0.002; // tune this
|
||||||
|
return Math.exp(-delta * sensitivity);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.zoomFactor /= wheelToZoomFactor(step);
|
||||||
|
this.zoomDelta -= step;
|
||||||
|
}
|
||||||
|
|
||||||
this.moving = this.wasm.update(elapsedTime);
|
this.moving = this.wasm.update(elapsedTime);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user