1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
extern crate web_sys;
use cgmath::{Vector2, Vector3};
pub type Vector2f = Vector2<f32>;
pub type Color = Vector3<f32>;
pub fn vec2f_zero() -> Vector2f {
Vector2f::new(0.0, 0.0)
}
#[allow(unused_macros)]
macro_rules! log {
( $( $t:tt )* ) => {
web_sys::console::log_1(&format!( $( $t )* ).into());
}
}
pub fn set_panic_hook() {
#[cfg(feature = "console_error_panic_hook")]
console_error_panic_hook::set_once();
}
#[inline]
pub fn clamp_f32(v: f32, a: f32, b: f32) -> f32 { b.min(v.max(a)) }