Ghost entities left behind by moving child entities


#1

I’m playing with the child entity hierarchy: I make a moon (a sphere) that is a child entity of a planet sphere that is the child entity of a sun sphere. If I rotate the sun, the planet-moon system goes around it, if I rotate the planet the moon goes around it. I can rotate the moon as well if I make it elliptical so I can tell. (I’m not expecting realistic planetary dynamics, just testing the hierarchical behavior). I wrote just one script that Quot.multiplies the local rotation and I put that script in every sphere. But after a while the orbiting bodies start to leave ghost entities behind. These look full bright or transparent depending on the angle you look at them. You cannot select them with the create dialog. As other spheres pass through them, you see what looks like correct intersections. The only way to get rid of a ghost entity is to re-boot the interface. Here is a picture of what my 9-moon 3-planet system looked like after it had been spinning for a while. The full bright red and green ellipses are the ghosts.
GhostEntities
Looking at the log, I see a lot of errors that look like this:

[DEBUG] [hifi.entities] WARNING entity moved during UpdateEntityOperator recursion

and an occasional:

[WARNING] [hifi.entities] EntityTree::addEntityMapEntry() found pre-existing id [entity-id: "{0a803092-93b4-4e83-b7d9-7d68e4f18ab8}" ]

Occasionally one of the moons will fall into its planet and continue spinning there.

After a while, my interface crashed, and I assume this has something to do with these ghost entities.
To repeat this problem: Create a bunch of spheres, make them elliptical so you can tell when they rotate. Mark them as collisionless. Link them into a hierarchy of moon, planets and a sun as the parent entity. I think the more child entities you have the sooner you will see the problem. Put the following script in each entity, children and parent, as a client script. Watch it spin for a while, eventually it will leave ghosts behind.

// LocalRot.js
//      Kayaker Magic Nov 22th 2017
//      Released under Creative Commons Attribution-ShareAlike 4.0 International
(function ()
{
    print("hello world");
    var mps=20.0;       //number of moves per second
    var ang=1.0;        //how far to rotate each move
    var quat=Quat.angleAxis(ang,{x:0.0, y:1.0, z:0.0}); //the rotation that does this
    var self = this;    //save this for later
    var myID;           //place to store my entityID for Rotate

    function Rotate()   //function to move the Entity around in a circle
    {
                                                //get the current rotation of this entity
        var myrot = Entities.getEntityProperties(myID, ["localRotation"]).localRotation;
        myrot = Quat.multiply(myrot,quat);
        Entities.editEntity(myID,{localRotation:myrot});
    } //end Orbit

    this.preload = function(entityID)
    {
        print("preload "+1000./mps);
        myID = entityID;        //save the entity id for orbit
                                        //set a timer to run orbit often
        self.intervalID = Script.setInterval(Rotate,1000.0/mps);
    }; //end loading preload

    this.unload = function()    //this never gets called if you remove the script....
    {
        Script.clearInterval(self.intervalID);
    }
} //end main function
)