threers 0.0.2

Drop-in three.js replacement for Rust and WebAssembly (wgpu) — THREE.* API, scene graph, PBR, post-fx, mesh BVH, CSG, headless render, and native media codecs
Documentation
use std::collections::HashMap;

#[derive(Debug, Default)]
pub struct IntersectionMap {
    pub intersection_set: HashMap<usize, Vec<usize>>,
    pub ids: Vec<usize>,
}

impl IntersectionMap {
    pub fn new() -> Self {
        Self::default()
    }

    pub fn add(&mut self, id: usize, intersection_id: usize) {
        if !self.intersection_set.contains_key(&id) {
            self.intersection_set.insert(id, Vec::new());
            self.ids.push(id);
        }
        self.intersection_set
            .get_mut(&id)
            .unwrap()
            .push(intersection_id);
    }
}