Refactor with threejs