mind0n

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

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

Share this post


Link to post
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 !

Share this post


Link to post
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

 

 

Share this post


Link to post
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

Share this post


Link to post
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!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.