cargo clippy & fmt

This commit is contained in:
Matthieu Baumann
2025-09-24 16:59:31 +02:00
parent 032bb57517
commit 9e8db0379b
8 changed files with 4449 additions and 4444 deletions

View File

@@ -30,7 +30,7 @@
fov *= 0.997;
rotation += 0.07;
aladin.setViewCenter2NorthPoleAngle(rotation)
aladin.setRotation(rotation)
aladin.setFoV(fov);
if (fov < 3 && fov > 0.5) {

View File

@@ -51,7 +51,7 @@ fn generate_shaders() -> std::result::Result<(), Box<dyn Error>> {
fs::write(tmp_path.clone(), &src)?;
Command::new("mono")
.args(&[
.args([
"/Users/matthieubaumann/Downloads/shader_minifier.exe",
"--format",
"text",

View File

@@ -1759,7 +1759,7 @@ impl App {
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();
self.camera

View File

@@ -3,7 +3,7 @@ use cgmath::Vector3;
use crate::camera::CameraViewPort;
use crate::math::angle::ToAngle;
use crate::math::projection::ProjectionType;
use crate::time::{DeltaTime, Time};
use crate::time::Time;
/// State for inertia
pub struct Inertia {
// Initial angular distance

View File

@@ -116,7 +116,6 @@ mod time;
use crate::{
camera::CameraViewPort, healpix::moc::SpaceMoc, math::lonlat::LonLatT, shader::ShaderManager,
time::DeltaTime,
};
use al_api::color::{Color, ColorRGBA};
@@ -137,10 +136,6 @@ use math::angle::ArcDeg;
pub struct WebClient {
// The app
app: App,
// The time between the previous and the current
// frame
dt: DeltaTime,
}
use al_api::hips::ImageMetadata;
@@ -167,9 +162,7 @@ impl WebClient {
let app = App::new(&gl, aladin_div, shaders, resources)?;
let dt = DeltaTime::zero();
let webclient = WebClient { app, dt };
let webclient = WebClient { app };
Ok(webclient)
}
@@ -196,7 +189,7 @@ impl WebClient {
/// Whether the view is moving or not
pub fn update(&mut self, dt: f64) -> Result<bool, JsValue> {
// 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
// world coordinates of the center of projection in (ra, dec)

View File

@@ -1,6 +1,5 @@
use crate::math;
use crate::math::angle::ToAngle;
use cgmath::One;
use cgmath::Vector3;
use cgmath::{BaseFloat, InnerSpace};
use cgmath::{Euler, Quaternion};
@@ -128,7 +127,7 @@ where
let qy = Self::from_axis_angle(&Vector3::unit_y(), lon);
let qx = Self::from_axis_angle(&Vector3::unit_x(), -lat);
(qy * qx)
qy * qx
}
/*pub fn from_sky_position(pos: &Vector3<S>) -> Rotation<S> {

File diff suppressed because it is too large Load Diff

View File

@@ -785,11 +785,12 @@ export let View = (function () {
return;
}
view.pinchZoomParameters.isPinching = true;
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();
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;
return;
@@ -1275,6 +1276,20 @@ export let View = (function () {
// disable text selection on IE
//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) {
e.preventDefault();
e.stopPropagation();
@@ -1295,24 +1310,13 @@ export let View = (function () {
if (typeof onWheelTriggeredFunction === 'function') {
onWheelTriggeredFunction(e)
} else {
// Default Aladin Lite zooming
view.delta = e.deltaY || e.detail || (-e.wheelDelta);
if (!view.throttledTouchPadZoom) {
view.throttledTouchPadZoom = () => {
const factor = Utils.detectTrackPad(e) ? 1.07 : 1.2;
const currZoomFactor = view.zoom.isZooming ? view.zoom.finalZoom : view.zoomFactor;
let newZoomFactor = view.delta > 0 ? currZoomFactor * factor : currZoomFactor / factor;
// inside case
view.zoom.apply({
stop: newZoomFactor,
duration: 100,
});
};
}
view.throttledTouchPadZoom();
// Default Aladin Lite zooming
const normalizedDelta = e.deltaY && normalizeWheel(e) || e.detail || (-e.wheelDelta);
// Accumulate the normalized delta
// We do not zoom because we cannot rely on "wheel" event
// being triggered at constant time steps
// The zoom is delayed to the redraw which is animation frame requested!
view.zoomDelta += normalizedDelta;
if (view.mode === View.TOOL_COLOR_PICKER) {
pickColor(xymouse);
@@ -1386,16 +1390,25 @@ export let View = (function () {
/**
* redraw the whole view
*/
View.prototype.redraw = function (timestamp) {
View.prototype.redraw = function (now) {
// request another frame
requestAnimFrame(this.redrawClbk);
// Elapsed time since last loop
const now = performance.now();
const elapsedTime = now - this.prevTime;
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);