Bug on Camera Target, NaN target coordinates

Hi all, I am trying to implement a new feature in my babylon project.

Before I explain my bug I will introduce a little bit what is the structure of my 3D models inside my scene.
In the hierarchy, a model, in my case, consists of a wrapper, identified by the name: “model_{UID}”. This wrapper has within it components that deal with:

  • for the position “Anchor_POS” (which is a child of “model_{UID}”);
  • for the rotation “Anchor_ROT” (which is a child of “Anchor_POS”);
  • for the scale “Anchor_SCL” (which is a child of “Anchor_ROT”).
    Within the last node, namely Anchor_SCL, I have my “model” which when created within the scene, in turn creates a “root.” Next, within my “root” are nodes that I want to get to → for example “locator1_RP_4_7_…”


In this functionality I am trying to bring wrappers of some models (thus containing the above mentioned information) to be children of these locators.

The main problem is that if I go too deep into the hierarchy, and then add a wrapper (e.g, named “model_AKI1T4YbfxCbGOGw8VsN”) to the “locator3_RP_4_7_8_10_11” of the “model_EC87tu04F5pOtEi7SYr7” and then recursively I want to add more models to the “locator2_RP_7_11” of the “model_AKI1T4YbfxCbGOGw8VsN”, if I move into the scene, the camera target coordinates some times go to NaN.

I tried to figure out if it was a problem with model vertices, then due to the complexity of the models being children of the locators, but I’m sure vertices are not the problem.
The behavior is very strange, since if I move only to the right, only to the left or only backward, the camera target coordinates never go to NaN, however as soon as I start moving forward the target goes to NaN. It is a behavior that I cannot explain.
The only explanation I’ve been able to come up with, but I don’t know if it actually makes sense, is that the depth of the hierarchy might be creating a problem, although I don’t really understand how this thing is supposed to send the Camera target to NaN.

However, I also tried to change an issue related to the parentage of model_{UID} becoming a child of locator. I tried in a scalar way to figure out the problem if it was hierarchy dependent. If I set that the model_{UID} is a child not of the locator but of the Anchor_SCL of the model referenced to the locator, this update of the target camera in NaN does not happen.
Is it possible that there is something that causes the camera target to explode due to the complexity of the hierarchy?

I know, it is very complex to explain, I hope with the attached pictures something can be understood.

Thanks a Lot

cc @PolygonalSun

Hey @Sabino,
Would you either be able to provide some kind of model or PG that can be used to repro the issue? It’ll be easier to figure out what’s going on with the camera and why the target is becoming NaN.

1 Like

Hey @Sabino !

Do you modify the target of the camera (or any its properties) by your code or do you rely only on the camera controls provided by the camera itself? If the former, most likely the bug is in your code. The complexity of the mesh hierarchy should not play role in this issue.

Hi @PolygonalSun ,
unfortunately, I cannot provide in the blog the models I use, however, if possible I would like your feedback. Maybe I can somehow pass you the models so that you can try them out ?
I know, it is a bit boring but it is the only way.
However I found a workaround for now, it seems that by setting the Anchor_SCL as the parent of the model_{UID}, the issue does not arise.
All very strange :smiley:

Hi @roland , I’m sure it’s a bug, but I’ve tried everything in my code, but I’m not going to do operations on the camera taget. The behavior seems strange to me.

Thx for the supports guys :smiley:

1 Like

So you don’t alter the camera movement with your code… Don’t you even use camera.setTarget ? Isn’t one of your Node’s position set to NaN, NaN, NaN?

Try to run this snippet:

    scene.transformNodes.forEach(n => {
        if (isNaN(n.position?.x)) { // or do a more sophisticated check here
            console.error(n.name, ' is invalid.')