extract threevs code to javascript class