added Detector, ported from the threejs examples