mirror of
https://github.com/cds-astro/aladin-lite.git
synced 2026-03-12 21:23:10 -07:00
fix cargo clippy
This commit is contained in:
@@ -21,6 +21,7 @@
|
||||
expandLayersControl: true,
|
||||
hipsList: [
|
||||
// High energy (Gamma and X-rays)
|
||||
'https://alasky.cds.unistra.fr/HIPS3D/GalfaHI',
|
||||
'CDS/P/HGPS/Flux',
|
||||
'CDS/P/Fermi/5',
|
||||
'CDS/P/Fermi/4',
|
||||
|
||||
@@ -64,7 +64,7 @@ path = "./al-api"
|
||||
|
||||
[dependencies.web-sys]
|
||||
version = "0.3.56"
|
||||
features = [ "console", "CssStyleDeclaration", "Document", "Element", "HtmlCollection", "CustomEvent", "CustomEventInit", "HtmlElement", "HtmlImageElement", "HtmlCanvasElement", "Blob", "ImageBitmap", "ImageData", "CanvasRenderingContext2d", "WebGlBuffer", "WebGlContextAttributes", "WebGlFramebuffer", "WebGlProgram", "WebGlShader", "WebGlUniformLocation", "WebGlTexture", "WebGlActiveInfo", "Headers", "Window", "Request", "RequestInit", "RequestMode", "RequestCredentials", "Response", "XmlHttpRequest", "XmlHttpRequestResponseType", "PerformanceTiming", "Performance", "Url", "ReadableStream", "File", "FileList",]
|
||||
features = [ "console", "CssStyleDeclaration", "Document", "Element", "HtmlCollection", "CustomEvent", "CustomEventInit", "HtmlElement", "HtmlImageElement", "HtmlCanvasElement", "Blob", "ImageBitmap", "ImageData", "CanvasRenderingContext2d", "WebGlBuffer", "WebGlContextAttributes", "WebGlFramebuffer", "WebGlProgram", "WebGlShader", "WebGlUniformLocation", "WebGlTexture", "WebGlActiveInfo", "Headers", "Window", "Request", "RequestInit", "RequestMode", "RequestCredentials", "Response", "XmlHttpRequest", "XmlHttpRequestResponseType", "PerformanceTiming", "Performance", "Url", "ReadableStream", "File", "FileList", "OffscreenCanvas", "OffscreenCanvasRenderingContext2d", "Worker", "WorkerOptions", "WorkerType"]
|
||||
|
||||
[dev-dependencies.image-decoder]
|
||||
package = "image"
|
||||
|
||||
@@ -692,36 +692,46 @@ impl App {
|
||||
ImageType::ImageRgba8u {
|
||||
image: Bitmap { image, .. },
|
||||
} => {
|
||||
let document = web_sys::window()
|
||||
.unwrap_abort()
|
||||
.document()
|
||||
.unwrap_abort();
|
||||
let canvas = document
|
||||
.create_element("canvas")?
|
||||
.dyn_into::<web_sys::HtmlCanvasElement>()?;
|
||||
canvas.set_width(image.width());
|
||||
canvas.set_height(image.height());
|
||||
let context = canvas
|
||||
.get_context("2d")?
|
||||
.unwrap_abort()
|
||||
.dyn_into::<web_sys::CanvasRenderingContext2d>()?;
|
||||
// Get the data once for all for the whole image
|
||||
// This takes time so better do it once and not repeatly
|
||||
context.draw_image_with_image_bitmap(
|
||||
image, 0.0, 0.0,
|
||||
let worker = create_worker()?;
|
||||
|
||||
//attach_onmessage(&worker);
|
||||
let msg = js_sys::Object::new();
|
||||
js_sys::Reflect::set(
|
||||
&msg,
|
||||
&"bitmap".into(),
|
||||
&image,
|
||||
)?;
|
||||
|
||||
// Transfer ownership (zero-copy)
|
||||
let transfer = js_sys::Array::of1(&image);
|
||||
worker.post_message_with_transfer(
|
||||
&msg, &transfer,
|
||||
)?;
|
||||
|
||||
let tile_size = *tile_size;
|
||||
let tile_depth = *tile_depth;
|
||||
|
||||
let num_cols = image.width() / tile_size;
|
||||
// Cut the png in several tile images. See page 3 of
|
||||
// https://aladin.cds.unistra.fr/java/DocTechHiPS3D.pdf
|
||||
let tile_depth = *tile_depth;
|
||||
let num_cols =
|
||||
(tile_depth as f32).sqrt().floor() as u32;
|
||||
let num_rows = ((tile_depth as f32)
|
||||
/ (num_cols as f32))
|
||||
.ceil()
|
||||
as u32;
|
||||
|
||||
let tile_size = *tile_size;
|
||||
let canvas = web_sys::OffscreenCanvas::new(
|
||||
image.width(),
|
||||
image.height(),
|
||||
)?;
|
||||
let context = canvas
|
||||
.get_context("2d")?
|
||||
.unwrap_abort()
|
||||
.dyn_into::<web_sys::OffscreenCanvasRenderingContext2d>()?;
|
||||
// Get the data once for all for the whole image
|
||||
// This takes time so better do it once and not repeatly
|
||||
context.draw_image_with_image_bitmap(
|
||||
image, 0.0, 0.0,
|
||||
)?;
|
||||
|
||||
let bytes = context
|
||||
.get_image_data(
|
||||
@@ -1842,3 +1852,12 @@ impl App {
|
||||
self.rendering
|
||||
}
|
||||
}
|
||||
|
||||
use web_sys::{Worker, WorkerOptions};
|
||||
pub fn create_worker() -> Result<Worker, JsValue> {
|
||||
let mut opts = WorkerOptions::new();
|
||||
opts._type(web_sys::WorkerType::Module);
|
||||
|
||||
let worker = Worker::new_with_options("worker.js", &opts)?;
|
||||
Ok(worker)
|
||||
}
|
||||
|
||||
@@ -377,7 +377,7 @@ impl HpxFreqTex {
|
||||
// size of the cube
|
||||
size: (u32, u32, u32),
|
||||
) -> Result<(), JsValue> {
|
||||
let cubic_tile = ImageBuffer::<R16I>::new(decoded_bytes, size.0, size.1, size.2);
|
||||
let cubic_tile = ImageBuffer::<R8U>::new(decoded_bytes, size.0, size.1, size.2);
|
||||
|
||||
cubic_tile.insert_into_3d_texture(&self.texture, &Vector3::<i32>::new(0, 0, 0))?;
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -440,6 +440,7 @@ export let Aladin = (function () {
|
||||
if (typeof hips === "string") {
|
||||
try {
|
||||
url = new URL(hips).href;
|
||||
id = url;
|
||||
} catch (e) {
|
||||
id = hips;
|
||||
}
|
||||
@@ -474,6 +475,8 @@ export let Aladin = (function () {
|
||||
hipsObj["name"] = name;
|
||||
}
|
||||
|
||||
console.log(hipsObj)
|
||||
|
||||
// Merge what is already in the cache for that HiPS with new properties
|
||||
// coming from the MOCServer
|
||||
this.hipsFavorites.push(hipsObj);
|
||||
@@ -630,10 +633,10 @@ export let Aladin = (function () {
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
let widgets = {};
|
||||
|
||||
let stack;
|
||||
// Add the layers control
|
||||
if (options.showLayersControl) {
|
||||
let stack = new Stack(this);
|
||||
stack = new Stack(this);
|
||||
widgets["stack"] = stack
|
||||
}
|
||||
|
||||
@@ -683,7 +686,7 @@ export let Aladin = (function () {
|
||||
}
|
||||
|
||||
if (options.expandLayersControl) {
|
||||
stack.click();
|
||||
stack && stack.click();
|
||||
}
|
||||
|
||||
this._applyMediaQueriesUI();
|
||||
|
||||
Reference in New Issue
Block a user