typpo / spacekit

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

Ring shader not working on SphereObjects with Ephem #57

Open mattstvan opened 2 years ago

mattstvan commented 2 years ago

First of all, this project looks fantastic and has a ton of potential. Kudos.

It appears that when rings are added to a SphereObject with ephem (i.e. being propagated around the scene), the rings become unlit. It seems to be related to the ring shader, but I'm no Three.js expert.

Example: image

My project uses webpack, but I can replicate the issue on a static page using the code below.

const viz = new Spacekit.Simulation(document.getElementById('main-container'), {
  jdPerSecond: 0.05,
  unitsPerAu: 100.0,
});

viz.createObject('sun', Spacekit.SpaceObjectPresets.SUN);
viz.createAmbientLight();
viz.createLight([0, 0, 0]);

const saturn = viz.createSphere('saturn', {
  textureUrl: './saturn.jpg',
  ephem: Spacekit.EphemPresets.SATURN,
  radius: 58232.503 / 149598000,
});
saturn.addRings(74270.580913, 140478.924731, './saturn_ring.png');
viz.getViewer().followObject(saturn, [-0.75, -0.75, 0.5]);