Jump to content

Maximum call stack size exceeded when apply click event on BILLBOARDMODE_ALL enabled meshes


mind0n
 Share

Recommended Posts

Refer to the link below, for billboard enabled meshes, I added mouse pick event so the camera will target to the mesh which being clicked.

However, after click on the mesh which BILLBOARDMODE_ALL is enabled, I got the following error.  I'd be really appreciated if anyone can fix this issue.  Thanks.

https://www.babylonjs-playground.com/#9XBPW4#2

Quote

38babylon.js:1 Uncaught RangeError: Maximum call stack size exceeded
    at m.h.computeWorldMatrix (babylon.js:1)
    at m.h.getAbsolutePosition (babylon.js:1)
    at n._getTargetPosition (babylon.js:1)
    at n._isSynchronizedViewMatrix (babylon.js:1)
    at n.c.getViewMatrix (babylon.js:1)
    at m.h.computeWorldMatrix (babylon.js:1)
    at m.h.getAbsolutePosition (babylon.js:1)
    at n._getTargetPosition (babylon.js:1)
    at n._isSynchronizedViewMatrix (babylon.js:1)
    at n.c.getViewMatrix (babylon.js:1)

        if (!m.actionManager){
            m.actionManager = new BABYLON.ActionManager(scene);
        }
        var act = new BABYLON.ExecuteCodeAction( BABYLON.ActionManager.OnPickTrigger, pick );
        m.actionManager.registerAction(act);
    function pick(evt){
        var mesh = evt.meshUnderPointer;
        camera.setTarget(mesh);
    }

 

error.PNG

Link to comment
Share on other sites

It's because of never ending recursive calls between (could be because of something else too)- 

Mesh.TransformNode.computeWorldMatrix -> ArcRotateCamera._getTargetPosition -> Mesh.TransformNode.getAbsolutePosition

though I don't know how to solve it :P It's like mesh and camera asking each other's world coordinates. dead lock !! lol !

Link to comment
Share on other sites

17 hours ago, ssaket said:

It's because of never ending recursive calls between (could be because of something else too)- 

Mesh.TransformNode.computeWorldMatrix -> ArcRotateCamera._getTargetPosition -> Mesh.TransformNode.getAbsolutePosition

though I don't know how to solve it :P It's like mesh and camera asking each other's world coordinates. dead lock !! lol !

Hi @ssaket or @Deltakosh,

I understand that this is a complicated problem.  So I adjusted the code to narrow down the problem.
Refer to the link below, the problem will only occur when 
billboardMode = BABYLON.Mesh.BILLBOARDMODE_ALL.  For BILLBOARDMODE_X, BILLBOARDMODE_Y or BILLBOARDMODE_Z, this issue never occurs.

And now just one click of the mesh will trigger the issue.  Hope this helps.

https://www.babylonjs-playground.com/#9XBPW4#2

 

 

Link to comment
Share on other sites

Hi :) 
Deltakosh should be around by tomorrow.
As mentioned, this happens because of a loop in calls,

Here's a temporary fix for until it's fixed;
Accessing absolutePosition directly, instead of getAbsolutePosition() function which forces computeWorldMatrix.
Include the snippet in your code, after the main babylonJs file.

BABYLON.ArcRotateCamera.prototype._getTargetPosition = function() {
    if (this._targetHost && this._targetHost.absolutePosition) {
        var e = this._targetHost.absolutePosition;
        this._targetBoundingCenter ? e.addToRef(this._targetBoundingCenter, this._target) : this._target.copyFrom(e)
    }
    var t = this._getLockedTargetPosition();
    return t || this._target
}

https://www.babylonjs-playground.com/#9XBPW4#4

Link to comment
Share on other sites

19 hours ago, aWeirdo said:

Hi :) 
Deltakosh should be around by tomorrow.
As mentioned, this happens because of a loop in calls,

Here's a temporary fix for until it's fixed;
Accessing absolutePosition directly, instead of getAbsolutePosition() function which forces computeWorldMatrix.
Include the snippet in your code, after the main babylonJs file.


BABYLON.ArcRotateCamera.prototype._getTargetPosition = function() {
    if (this._targetHost && this._targetHost.absolutePosition) {
        var e = this._targetHost.absolutePosition;
        this._targetBoundingCenter ? e.addToRef(this._targetBoundingCenter, this._target) : this._target.copyFrom(e)
    }
    var t = this._getLockedTargetPosition();
    return t || this._target
}

https://www.babylonjs-playground.com/#9XBPW4#4

Thank you so much!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...