Spatial getWorldRotation() NaN?

I ran into some troubles while adding more stuff to my game.

It had been all dandy for some time, and while adjusting something completely

unrelated I started getting a nullpointer from one of my billboard controls attached to DamageTexts.

After debugging the client I concluded that the


had all values at “NaN”.

And the nullpointer occured when the billboard control attempted to align towards camera.


private void rotateScreenAligned(Camera camera) {

// coopt diff for our in direction:


// coopt loc for our left direction:


orient.fromAxes(left, camera.getUp(), look);

Node parent = spatial.getParent();

Quaternion rot=new Quaternion().fromRotationMatrix(orient);

if ( parent != null ) {

rot = parent.getWorldRotation().inverse().multLocal(rot); // HERE







Considering the world rotation of the parent was at NaN, the inverse() of it would return a null object.

So overriding the controlRender I concluded that this was the cause of the nullpointer crash.


bc = new BillboardControl() {


protected void controlRender(RenderManager rm, ViewPort vp) {

if (getParent() == null) {

System.out.println(“Parent null”);


} else if (getParent().getWorldRotation().inverse() == null) {

System.out.println(“Parent world rotation null”);



super.controlRender(rm, vp);




The parent is not null.

However to my questions to you:

Why would the worldRotation be invalid?

Why is this happening randomly?

And also, it shows Player as parent, but I’m adding the BillboardControl to the DamageText, a sub node of the player node.

We don’t really get random messed up quaternions or wrong spatials on getParent so it must be in your code. Do you extend any classes? Override stuff? You know you’re not supposed to change the locations and rotations in controlRender, yes?

I’m extending nodes, but not overriding any methods.

Also I’m not changing any stuff in controlRender, the only reason I override it here was to debug/figure out what was throwing the nullpointer.

I should also say that this happens very occasionally.

The quickest way I can reproduce it is to spawn ~100 npcs,

shoot through them, spawning alot of damage texts (billboard control bitmaptext).

Eventually anywhere between 10 and 60 seconds, the nullpointer will pop up.

A thousand damage texts can be created and disposed in less than a minute.

Node structure of players is like this.


  • Players node
  • Player
  • DamageTexts node
  • DamageText
  • HealthBar
  • CharacterName


    I just cant figure out why world rotation at any time could be NaN, is there any way I could continue troubleshooting?

    Could it be NaN if it was not attached to any parent and not added to the rootNode?

Try breakpointing the variable for NaN going into it and then looking at the call stack?