mirror of
https://github.com/cds-astro/aladin-lite.git
synced 2026-06-12 19:11:42 -07:00
fix cargo clippy
This commit is contained in:
@@ -21,6 +21,7 @@
|
|||||||
expandLayersControl: true,
|
expandLayersControl: true,
|
||||||
hipsList: [
|
hipsList: [
|
||||||
// High energy (Gamma and X-rays)
|
// High energy (Gamma and X-rays)
|
||||||
|
'https://alasky.cds.unistra.fr/HIPS3D/GalfaHI',
|
||||||
'CDS/P/HGPS/Flux',
|
'CDS/P/HGPS/Flux',
|
||||||
'CDS/P/Fermi/5',
|
'CDS/P/Fermi/5',
|
||||||
'CDS/P/Fermi/4',
|
'CDS/P/Fermi/4',
|
||||||
|
|||||||
+1
-1
@@ -64,7 +64,7 @@ path = "./al-api"
|
|||||||
|
|
||||||
[dependencies.web-sys]
|
[dependencies.web-sys]
|
||||||
version = "0.3.56"
|
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]
|
[dev-dependencies.image-decoder]
|
||||||
package = "image"
|
package = "image"
|
||||||
|
|||||||
+40
-21
@@ -692,36 +692,46 @@ impl App {
|
|||||||
ImageType::ImageRgba8u {
|
ImageType::ImageRgba8u {
|
||||||
image: Bitmap { image, .. },
|
image: Bitmap { image, .. },
|
||||||
} => {
|
} => {
|
||||||
let document = web_sys::window()
|
let worker = create_worker()?;
|
||||||
.unwrap_abort()
|
|
||||||
.document()
|
//attach_onmessage(&worker);
|
||||||
.unwrap_abort();
|
let msg = js_sys::Object::new();
|
||||||
let canvas = document
|
js_sys::Reflect::set(
|
||||||
.create_element("canvas")?
|
&msg,
|
||||||
.dyn_into::<web_sys::HtmlCanvasElement>()?;
|
&"bitmap".into(),
|
||||||
canvas.set_width(image.width());
|
&image,
|
||||||
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,
|
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
|
// 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
|
// Cut the png in several tile images. See page 3 of
|
||||||
// https://aladin.cds.unistra.fr/java/DocTechHiPS3D.pdf
|
// 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)
|
let num_rows = ((tile_depth as f32)
|
||||||
/ (num_cols as f32))
|
/ (num_cols as f32))
|
||||||
.ceil()
|
.ceil()
|
||||||
as u32;
|
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
|
let bytes = context
|
||||||
.get_image_data(
|
.get_image_data(
|
||||||
@@ -1842,3 +1852,12 @@ impl App {
|
|||||||
self.rendering
|
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 of the cube
|
||||||
size: (u32, u32, u32),
|
size: (u32, u32, u32),
|
||||||
) -> Result<(), JsValue> {
|
) -> 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))?;
|
cubic_tile.insert_into_3d_texture(&self.texture, &Vector3::<i32>::new(0, 0, 0))?;
|
||||||
|
|
||||||
|
|||||||
+4349
-4349
File diff suppressed because it is too large
Load Diff
+6
-3
@@ -440,6 +440,7 @@ export let Aladin = (function () {
|
|||||||
if (typeof hips === "string") {
|
if (typeof hips === "string") {
|
||||||
try {
|
try {
|
||||||
url = new URL(hips).href;
|
url = new URL(hips).href;
|
||||||
|
id = url;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
id = hips;
|
id = hips;
|
||||||
}
|
}
|
||||||
@@ -474,6 +475,8 @@ export let Aladin = (function () {
|
|||||||
hipsObj["name"] = name;
|
hipsObj["name"] = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log(hipsObj)
|
||||||
|
|
||||||
// Merge what is already in the cache for that HiPS with new properties
|
// Merge what is already in the cache for that HiPS with new properties
|
||||||
// coming from the MOCServer
|
// coming from the MOCServer
|
||||||
this.hipsFavorites.push(hipsObj);
|
this.hipsFavorites.push(hipsObj);
|
||||||
@@ -630,10 +633,10 @@ export let Aladin = (function () {
|
|||||||
|
|
||||||
////////////////////////////////////////////////////
|
////////////////////////////////////////////////////
|
||||||
let widgets = {};
|
let widgets = {};
|
||||||
|
let stack;
|
||||||
// Add the layers control
|
// Add the layers control
|
||||||
if (options.showLayersControl) {
|
if (options.showLayersControl) {
|
||||||
let stack = new Stack(this);
|
stack = new Stack(this);
|
||||||
widgets["stack"] = stack
|
widgets["stack"] = stack
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -683,7 +686,7 @@ export let Aladin = (function () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (options.expandLayersControl) {
|
if (options.expandLayersControl) {
|
||||||
stack.click();
|
stack && stack.click();
|
||||||
}
|
}
|
||||||
|
|
||||||
this._applyMediaQueriesUI();
|
this._applyMediaQueriesUI();
|
||||||
|
|||||||
Reference in New Issue
Block a user