Skip to content
Snippets Groups Projects
Commit 95cd7b56 authored by Jerome Chetelat's avatar Jerome Chetelat
Browse files

Fixed rust file server

parent 77d40378
Branches
No related tags found
No related merge requests found
Pipeline #12171 passed
......@@ -27,7 +27,7 @@ dependencies = [
"actix-utils",
"derive_more",
"either",
"futures 0.3.5",
"futures",
"http",
"log",
"trust-dns-proto",
......@@ -43,7 +43,7 @@ dependencies = [
"actix-service",
"actix-web",
"derive_more",
"futures 0.3.5",
"futures",
]
[[package]]
......@@ -120,7 +120,7 @@ version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a60f9ba7c4e6df97f3aacb14bb5c0cd7d98a49dcbaed0d7f292912ad9a6a3ed2"
dependencies = [
"quote 1.0.7",
"quote",
"syn",
]
......@@ -223,7 +223,7 @@ dependencies = [
"actix-utils",
"derive_more",
"either",
"futures 0.3.5",
"futures",
"log",
]
......@@ -239,7 +239,7 @@ dependencies = [
"bitflags",
"bytes",
"either",
"futures 0.3.5",
"futures",
"log",
"pin-project",
"slab",
......@@ -267,7 +267,7 @@ dependencies = [
"bytes",
"derive_more",
"encoding_rs",
"futures 0.3.5",
"futures",
"fxhash",
"log",
"mime",
......@@ -287,8 +287,8 @@ version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a71bf475cbe07281d0b3696abb48212db118e7e23219f13596ce865235ff5766"
dependencies = [
"proc-macro2 1.0.19",
"quote 1.0.7",
"proc-macro2",
"quote",
"syn",
]
......@@ -352,8 +352,8 @@ version = "0.1.36"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a265e3abeffdce30b2e26b7a11b222fe37c6067404001b434101457d0385eb92"
dependencies = [
"proc-macro2 1.0.19",
"quote 1.0.7",
"proc-macro2",
"quote",
"syn",
]
......@@ -513,13 +513,13 @@ name = "client"
version = "0.1.0"
dependencies = [
"console_error_panic_hook",
"futures 0.3.5",
"futures",
"js-sys",
"nalgebra",
"serde 1.0.115",
"stl_io",
"wasm-bindgen",
"wasm-bindgen-futures 0.4.17",
"wasm-bindgen-futures",
"wasm-bindgen-test",
"web-sys",
"wee_alloc",
......@@ -642,8 +642,8 @@ version = "0.99.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "298998b1cf6b5b2c8a7b023dfd45821825ce3ba8a8af55c921a0e734e4653f76"
dependencies = [
"proc-macro2 1.0.19",
"quote 1.0.7",
"proc-macro2",
"quote",
"syn",
]
......@@ -687,8 +687,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bc4bfcfacb61d231109d1d55202c1f33263319668b168843e02ad4652725ec9c"
dependencies = [
"heck",
"proc-macro2 1.0.19",
"quote 1.0.7",
"proc-macro2",
"quote",
"syn",
]
......@@ -721,8 +721,8 @@ version = "0.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aa4da3c766cd7a0db8242e326e9e4e081edd567072893ed320008189715366a4"
dependencies = [
"proc-macro2 1.0.19",
"quote 1.0.7",
"proc-macro2",
"quote",
"syn",
"synstructure",
]
......@@ -767,12 +767,6 @@ version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7"
[[package]]
name = "futures"
version = "0.1.29"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1b980f2816d6ee8673b6517b52cb0e808a180efc92e5c19d02cdda79066703ef"
[[package]]
name = "futures"
version = "0.3.5"
......@@ -828,8 +822,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d0b5a30a4328ab5473878237c447333c093297bded83a4983d10f4deea240d39"
dependencies = [
"proc-macro-hack",
"proc-macro2 1.0.19",
"quote 1.0.7",
"proc-macro2",
"quote",
"syn",
]
......@@ -1547,8 +1541,8 @@ version = "0.4.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6a0ffd45cf79d88737d7cc85bfd5d2894bee1139b356e616fe85dc389c61aaf7"
dependencies = [
"proc-macro2 1.0.19",
"quote 1.0.7",
"proc-macro2",
"quote",
"syn",
]
......@@ -1582,22 +1576,13 @@ version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eba180dafb9038b050a4c280019bbedf9f2467b61e5d892dcad585bb57aadc5a"
[[package]]
name = "proc-macro2"
version = "0.4.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759"
dependencies = [
"unicode-xid 0.1.0",
]
[[package]]
name = "proc-macro2"
version = "1.0.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "04f5f085b5d71e2188cb8271e5da0161ad52c3f227a661a3c135fdf28e258b12"
dependencies = [
"unicode-xid 0.2.1",
"unicode-xid",
]
[[package]]
......@@ -1606,22 +1591,13 @@ version = "1.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0"
[[package]]
name = "quote"
version = "0.6.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1"
dependencies = [
"proc-macro2 0.4.30",
]
[[package]]
name = "quote"
version = "1.0.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aa563d17ecb180e500da1cfd2b028310ac758de548efdd203e18f283af693f37"
dependencies = [
"proc-macro2 1.0.19",
"proc-macro2",
]
[[package]]
......@@ -1815,8 +1791,8 @@ version = "1.0.115"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "609feed1d0a73cc36a0182a840a9b37b4a82f0b1150369f0536a9e3f2a31dc48"
dependencies = [
"proc-macro2 1.0.19",
"quote 1.0.7",
"proc-macro2",
"quote",
"syn",
]
......@@ -1961,9 +1937,9 @@ version = "1.0.35"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fb7f4c519df8c117855e19dd8cc851e89eb746fe7a73f0157e0d95fdec5369b0"
dependencies = [
"proc-macro2 1.0.19",
"quote 1.0.7",
"unicode-xid 0.2.1",
"proc-macro2",
"quote",
"unicode-xid",
]
[[package]]
......@@ -1972,10 +1948,10 @@ version = "0.12.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b834f2d66f734cb897113e34aaff2f1ab4719ca946f9a7358dba8f8064148701"
dependencies = [
"proc-macro2 1.0.19",
"quote 1.0.7",
"proc-macro2",
"quote",
"syn",
"unicode-xid 0.2.1",
"unicode-xid",
]
[[package]]
......@@ -2122,7 +2098,7 @@ dependencies = [
"async-trait",
"enum-as-inner",
"failure",
"futures 0.3.5",
"futures",
"idna",
"lazy_static",
"log",
......@@ -2141,7 +2117,7 @@ checksum = "6f90b1502b226f8b2514c6d5b37bafa8c200d7ca4102d57dc36ee0f3b7a04a2f"
dependencies = [
"cfg-if",
"failure",
"futures 0.3.5",
"futures",
"ipconfig",
"lazy_static",
"log",
......@@ -2197,12 +2173,6 @@ version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "caaa9d531767d1ff2150b9332433f32a24622147e5ebb1f26409d5da67afd479"
[[package]]
name = "unicode-xid"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc"
[[package]]
name = "unicode-xid"
version = "0.2.1"
......@@ -2265,8 +2235,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c2ca2a14bc3fc5b64d188b087a7d3a927df87b152e941ccfbc66672e20c467ae"
dependencies = [
"nom 4.2.3",
"proc-macro2 1.0.19",
"quote 1.0.7",
"proc-macro2",
"quote",
"syn",
]
......@@ -2323,25 +2293,12 @@ dependencies = [
"bumpalo",
"lazy_static",
"log",
"proc-macro2 1.0.19",
"quote 1.0.7",
"proc-macro2",
"quote",
"syn",
"wasm-bindgen-shared",
]
[[package]]
name = "wasm-bindgen-futures"
version = "0.3.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "83420b37346c311b9ed822af41ec2e82839bfe99867ec6c54e2da43b7538771c"
dependencies = [
"cfg-if",
"futures 0.1.29",
"js-sys",
"wasm-bindgen",
"web-sys",
]
[[package]]
name = "wasm-bindgen-futures"
version = "0.4.17"
......@@ -2360,7 +2317,7 @@ version = "0.2.67"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "97c57cefa5fa80e2ba15641578b44d36e7a64279bc5ed43c6dbaf329457a2ed2"
dependencies = [
"quote 1.0.7",
"quote",
"wasm-bindgen-macro-support",
]
......@@ -2370,8 +2327,8 @@ version = "0.2.67"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "841a6d1c35c6f596ccea1f82504a192a60378f64b3bb0261904ad8f2f5657556"
dependencies = [
"proc-macro2 1.0.19",
"quote 1.0.7",
"proc-macro2",
"quote",
"syn",
"wasm-bindgen-backend",
"wasm-bindgen-shared",
......@@ -2385,27 +2342,26 @@ checksum = "93b162580e34310e5931c4b792560108b10fd14d64915d7fff8ff00180e70092"
[[package]]
name = "wasm-bindgen-test"
version = "0.2.50"
version = "0.3.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a2d9693b63a742d481c7f80587e057920e568317b2806988c59cd71618bc26c1"
checksum = "7d92df9d5715606f9e48f85df3b78cb77ae44a2ea9a5f2a785a97bd0066b9300"
dependencies = [
"console_error_panic_hook",
"futures 0.1.29",
"js-sys",
"scoped-tls",
"wasm-bindgen",
"wasm-bindgen-futures 0.3.27",
"wasm-bindgen-futures",
"wasm-bindgen-test-macro",
]
[[package]]
name = "wasm-bindgen-test-macro"
version = "0.2.50"
version = "0.3.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0789dac148a8840bbcf9efe13905463b733fa96543bfbf263790535c11af7ba5"
checksum = "51611ce8e84cba89379d91fc5074bacc5530f69da1c09a2853d906129d12b3b8"
dependencies = [
"proc-macro2 0.4.30",
"quote 0.6.13",
"proc-macro2",
"quote",
]
[[package]]
......
......@@ -68,5 +68,5 @@ console_error_panic_hook = "0.1.5"
# These crates are used for running unit tests.
[dev-dependencies]
wasm-bindgen-test = "0.2.45"
wasm-bindgen-test = "0.3.17"
......@@ -68,8 +68,8 @@ impl App {
let model_matrix = Isometry3::new(Vector3::new(0., 0., 0.), nalgebra::zero());
let eye = Point3::new(0.0, 0.0, 1.0);
let target = Point3::new(0.0, 0.0, 0.0);
let view = Isometry3::look_at_rh(&eye, &target, &Vector3::y());
let target = Point3::new(1.0, 0.0, 0.0);
let view = Isometry3::look_at_rh(&eye, &target, &Vector3::z());
let normal_matrix = view.inverse();
let projection_uniform_location = context
......@@ -170,7 +170,6 @@ async fn get_file(url: &str) -> Result<Vec<u8>, JsValue> {
opts.method("GET");
opts.mode(RequestMode::Cors);
let url = "http://localhost:8080/files/output.stl";
unsafe {
console::log_1(&JsValue::from_str(&url));
}
......@@ -179,7 +178,6 @@ async fn get_file(url: &str) -> Result<Vec<u8>, JsValue> {
let mut headers = request.headers();
headers.set("Accept", "application/vnd.ms-pki.stl")?;
headers.set("responseType", "arraybuffer")?;
let window = window();
let resp_value = JsFuture::from(window.fetch_with_request(&request)).await?;
......@@ -217,8 +215,10 @@ pub async fn main_js() -> Result<(), JsValue> {
console_error_panic_hook::set_once();
// Your code goes here!
unsafe {
console::log_1(&JsValue::from_str("Hello world!"));
let mut file_data: Vec<u8> = get_file("http://localhost:8080/").await?;
}
let mut file_data: Vec<u8> = get_file("http://localhost:8080/files/output.stl").await?;
let canvas = document().get_element_by_id("canvas").unwrap();
let canvas: web_sys::HtmlCanvasElement = canvas.dyn_into::<web_sys::HtmlCanvasElement>()?;
......@@ -237,26 +237,36 @@ pub async fn main_js() -> Result<(), JsValue> {
.faces
.iter()
.flat_map(|triangle: &IndexedTriangle| triangle.vertices.iter().copied())
//.flat_map(|vertex| vertex.iter().copied())
.map(|val: usize| val as u32)
.collect();
// let indices: Vec<u32> = mesh
// .faces
// .iter()
// .map(|triangle: IndexedTriangle| triangle.vertices.iter())
// .collect()
// .map();
let normals: Vec<f32> = mesh
.faces
.iter()
.flat_map(|triangle: &IndexedTriangle| triangle.normal.iter().copied())
.collect();
let vertex_buffer = app
.context
.create_buffer()
.ok_or("failed to create vertex_buffer")?;
let indices_buffer = app
app.context
.bind_buffer(WebGlRenderingContext::ARRAY_BUFFER, Some(&vertex_buffer));
let normal_buffer = app
.context
.create_buffer()
.ok_or("failed to create buffer")?;
.ok_or("Failed to create normal buffer")?;
app.context
.bind_buffer(WebGlRenderingContext::ARRAY_BUFFER, Some(&vertex_buffer));
.bind_buffer(WebGlRenderingContext::ARRAY_BUFFER, Some(&normal_buffer));
let indices_buffer = app
.context
.create_buffer()
.ok_or("failed to create indices buffer")?;
app.context.bind_buffer(
WebGlRenderingContext::ELEMENT_ARRAY_BUFFER,
Some(&indices_buffer),
......@@ -273,6 +283,8 @@ pub async fn main_js() -> Result<(), JsValue> {
unsafe {
let vert_array = js_sys::Float32Array::view(&vertices);
let indices_array = js_sys::Uint32Array::view(&indices);
let normal_array = js_sys::Float32Array::view(&normals);
console::log_1(&JsValue::from(&vert_array));
// Filling data into WebGl buffers
app.context.buffer_data_with_array_buffer_view(
......@@ -286,13 +298,19 @@ pub async fn main_js() -> Result<(), JsValue> {
&indices_array,
WebGlRenderingContext::STATIC_DRAW,
);
app.context.buffer_data_with_array_buffer_view(
WebGlRenderingContext::ARRAY_BUFFER,
&normal_array,
WebGlRenderingContext::STATIC_DRAW,
);
}
app.context
.vertex_attrib_pointer_with_i32(0, 3, WebGlRenderingContext::FLOAT, false, 0, 0);
unsafe {
console::log_1(&JsValue::from_str("Transfering projection matrix to webgl"));
}
app.context
.vertex_attrib_pointer_with_i32(0, 3, WebGlRenderingContext::FLOAT, false, 0, 0);
app.context.uniform_matrix4fv_with_f32_array(
Some(&app.projection_location),
......@@ -318,6 +336,8 @@ pub async fn main_js() -> Result<(), JsValue> {
app.context.clear_color(0.0, 0.0, 0.0, 1.0);
app.context.clear(WebGlRenderingContext::COLOR_BUFFER_BIT);
let ext = app.context.get_extension("OES_element_index_uint")?;
// Calling draw with indices
app.context.draw_elements_with_i32(
WebGlRenderingContext::TRIANGLES,
......
......@@ -5,6 +5,7 @@ varying highp vec3 v_lighting;
void main() {
gl_FragColor = vec4(v_lighting, 1.0);
// gl_FragColor = vec4(1.0,0.0,0.0,1.0);
}
"#;
......@@ -13,13 +13,12 @@ varying highp vec3 v_lighting;
void main() {
gl_Position = u_projection * u_modelview * vec4(a_position, 1.0);
highp vec3 ambiantLight = vec3(0.6, 0.6, 0.6);
highp vec3 ambiant_light = vec3(0.6, 0.6, 0.6);
highp vec3 dir_light_col = vec3(0.5, 0.5, 0.75);
highp vec3 dir_vector = vec3(0.85, 0.85, 0.85);
highp vec3 dir_vector = vec3(0.85, 0.8, 0.75);
highp vec4 adapted_normal = u_normal * vec4(a_normal, 1.0);
highp float intensity = max(dot(adapted_normal.xyz, dir_vector), 0.0);
v_lighting = ambiantLight + (dir_light_col * intensity);
v_lighting = ambiant_light + (dir_light_col * intensity);
}
"#;
......@@ -19,13 +19,12 @@ fn web_test() {
// This runs a unit test in the browser, and in addition it supports asynchronous Future APIs.
#[wasm_bindgen_test(async)]
fn async_test() -> impl Future<Item = (), Error = JsValue> {
async fn async_test() {
// Creates a JavaScript Promise which will asynchronously resolve with the value 42.
let promise = js_sys::Promise::resolve(&JsValue::from(42));
// Converts that Promise into a Future.
// The unit test will wait for the Future to resolve.
JsFuture::from(promise).map(|x| {
let x = JsFuture::from(promise).await.unwrap();
assert_eq!(x, 42);
})
}
......@@ -46,8 +46,8 @@ async fn main() -> std::io::Result<()> {
.max_age(3600)
.finish(),
)
.route("/filename:.*", web::get().to(file_service))
// .service(fs::Files::new("/files", "./regions").show_files_listing())
//.route("/files:.*", web::get().to(file_service))
.service(fs::Files::new("/files", "./regions").show_files_listing())
//.route("/files/{x}/{y}", web::get().to(las_files))
});
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment