typpo / spacekit

Javascript library for 3D space visualizations
https://typpo.github.io/spacekit/
MIT License
521 stars 39 forks source link

Add support for orbiting ShapeObjects #31

Closed typpo closed 4 years ago

typpo commented 4 years ago

Now ShapeObjects (e.g. rendered asteroids) can move according to their Kepler orbits.

This change makes it so that subclasses of SpaceObject (SphereObject, RotatingObject, ShapeObject) compute their orbital position via SpaceObject orbit whenever possible. Standardizing this is nice because SpaceObject contains the logic for drawing orbital paths, deciding when to update, whether to draw debug axes, etc.

It also adds a basic asteroid flyby example, in which an exaggerated-sized Earth/asteroid pass by one another to demonstrate SphereObject and ShapeObject following an orbit.